Getting started¶
With the exception of the gui, the PyLorentz code is intended to be run in Jupyter notebooks and several examples are provided. You can clone the repo from the github page, fork the project, or download the files directly in a .zip.
Several standard packages are required which can be installed with conda or pip, and .yml files are included in the /envs/
folder. Select the appropriate file for your system and create the environment from a command line with:
>>> conda env create -f environment.yml
Activate with either:
>>> source activate PyLorentz
or:
>>> conda activate PyLorentz
depending on operating system before opening a notebook.
Example Data¶
We recommend running the template files provided in the /Examples/
directory with the provided example data. The PyTIE template will show you how to download an experimental dataset from the Materials Data Facility, which contains a through focus series (tfs) in both flipped and unflipped orientations as well as an aligned image stack. These files are ready to be used in the TIE_template.ipynb
.
For SIM_template.ipynb
, there is an example_mumax.ovf
file already in the repository, which can be used directly.
Data Organization¶
PyTIE requires all of the image data to be contained within one main working directory. The exact setup will depend on if you have one single through focus series (tfs) or two.
If you have both a flip and unflip stack your data should be set up as follows:
datafolder/ flip/ -im1.dm3
-im2.dm3
...
+im1.dm3
+im2.dm3
...
0im.dm3
unflip/ -im1.dm3
-im2.dm3
.
.
+im1.dm3
+im2.dm3
.
.
0im.dm3
flsfile.fls
full_align.tif
If your flip and unflip filenames aren’t the same you can also have two fls files, one for each tfs. In that case just change the argument in load_data: flip_fls_file = "flip/fls/path"
However if you have just one stack (no flip stack) then your data should be in a folder labeled ‘tfs’
datafolder/ tfs/ -im1.dm3
-im2.dm3
...
+im1.dm3
+im2.dm3
...
0im.dm3
flsfile.fls
full_align.tif
The full_align.tif
is a 3D tifstack of the aligned flipped and unflipped images. It is ordered from most underfocus to most overfocus, first unflipped then flipped images, e.g. for a 5 image series:
[-2 , -1 , 0 , +1 , +2 , -2f , -1f , 0f , +1f , +2f]
The .fls file¶
The fls file is a text file that makes it easier for the program to read a tfs of images. It contains, in order:
- The number of images in the through focal series
- Names of the images from most underfocus to most overfocus; the middle image should be the in-focus image.
- The defocus values, which should be the same for both over and under focus. There should be \(\frac{\text{#images} - 1}{2}\) total defocus values.
For example, the fls file would be the following for a 5-image stack:
5
under2.dm3
under1.dm3
infocus.dm3
over1.dm3
over2.dm3
defocus_val_1
defocus_val_2
If you have only one tfs, then you will only have one fls file. If you have two tfs and the files are named differently, you will need two fls files. If the files are named symmetrically between the flip and unflip images, only one fls file is needed (as is the case in the example data).