.. _loading-saving: Loading and Saving ================== Loading and saving data is performed via the *Load* and *Save* options on the *File* menu. Loading ------- .. _load-dataset: Load Dataset ************ When *Load dataset* is selected, the following dialog will appear: .. image:: ../../_static/loading_screen.png :alt: Initial Load dialog This allows you to select the data you wish to load; The Sample entry should be used to select the first projection TIFF file, the remaining TIFF files in the directory will be automatically detected if their filename matches the pattern. The loading dialog will try to automatically find associated files including flat fields, dark frames, 180 degree projections and sample logs. Once data has been selected, its shape is inspected and the stack index fields are populated as shown below: .. image:: ../../_static/loading_screen_filled.png :alt: Load dialog after selecting data The *Start* and *End* fields control the range of images that are loaded and *Increment* defines the interval at which images are selected. To quickly load only 10 images from a stack, press the preview button, which will set a large enough *Increment*. *Pixel Bit Depth* is used for the estimated memory size calculation, typically images will use 32bit floating point numbers as the pixel format so this can be left at the default value of *float32*. .. note:: Note that the image filenames must be in the form TITLE_XXXXX, with XXXXX being the image number. Load Images *********** Load images can be used to load a stack contained in a directory or a single image. Load NeXus File *************** NeXus Files can be loaded by selecting the "Load NeXus file" on the File menu. This brings up the NeXus Load dialog shown below. .. image:: ../../_static/nexus_loading_window.png :alt: NeXus Load Dialog From here you can choose a NeXus file that you wish to load. The program will then scan its contents and check for a :code:`NXtomo` entry. If an entry is found, information about the file will be displayed in the dialog. The data sizes are also displayed so that a user can check that the image key and data field have the same number of elements. The "Use?" checkbox can be used to select which images you wish to load. If the required information could be found in the file, then the OK button will be enabled. Otherwise the button will be disabled. As in the case of loading a dataset, there is also the option to load a subset of the projection data either by manually setting an increment or by clicking on the "Preview" button. The "All" button can be used to change the increment so that the entire projection data is loaded. There are also options for setting pixel size and pixel bit depth. From here, you can press OK to load the file as a dataset. The name given to the images will be taken from the :code:`title` field in the NeXus file if one is found, otherwise the images are given the name "NeXus Data." Load log for stack ------------------ This can be used to load a log file with metadata about the stack. It supports text and CSV files generated by IMAT. The expected header for a text file is: :code:`TIME STAMP IMAGE TYPE IMAGE COUNTER COUNTS BM3 before image COUNTS BM3 after image` and for a CSV file :code:`TIME STAMP,IMAGE TYPE,IMAGE COUNTER,COUNTS BM3 before image,COUNTS BM3 after image` Note that the log can also be chosen in the :ref:`load-dataset` dialog. Load projection angles ---------------------- This can be used to load a file with projection angles. Angles are expected in DEGREES as comma separated values on a single line, or a single angle value per line. 180 Degree Projections ---------------------- In the case of both tiffs and NeXus files, Mantid Imaging will try to find a 180 projection in the data. If one has not been found, then it will try to look for a projection that is <= 1 degree away from 180. Should this fail then you will be asked if you wish to use the next closest image. Bear in mind that the absence of a 180 degree projection means that the "Correlate 0 and 180" algorithm will not be available for the reconstruction. A new 180 projection can be loaded with the :code:`Load 180 degree projection` option. This will override any already loaded 180 projection. This option will only work correctly with a stack loaded through the :ref:`load-dataset` method. Saving ------ The *Save* options are only enabled when at least one stack is loaded. Save as Image Files ******************* When *Save as Image Files* is selected the save images dialog appears: .. image:: ../../_static/gui_save_dialog.png :alt: Save dialog This prompts you to select the image stack you wish to save, the directory in which you wish to save it and the name prefix. In the case of TIFF and FITS the individual image filenames will be a concatenation of this prefix and the index of the image in the stack. The *Overwrite* option removes checking for existing data of the same name. When disabled an error will be raised if the specified output directory is not empty prior to saving. Save as a NeXus File ******************** When *Save as NeXus File* is selected the save NeXus dialog appears. Only Datasets with sample images data can be saved as NeXus files. A sample name and an output directory are required before a save can be attempted. The image data (excluding recons) can be saved as either float 32 or int 16. Users should be aware that there will be data loss when saving as int. .. note:: Recon data is currently saved as float16. Dataset Tree View ----------------- When a dataset has been successfully loaded, it will be possible to see its elements listed in the dataset tree view. .. image:: ../../_static/dataset_tree_view.png :alt: Dataset tree view Adding / Replacing Data *********************** The stacks that comprise an existing dataset can be deleted or -- in the case of *strict* datasets only -- replaced. This can be done by right clicking an item in the dataset tree view and choosing the Add / Replace Stack option. .. image:: ../../_static/add_to_dataset_dialog.png :alt: Dataset tree view As in the case of loading images from the main menu, selecting a single file will cause Mantid Imaging to load all like images in the same directory. The type of images that you wish to load can be selected from the drop-down menu. If this image type already exists in the dataset then the new images will replace it and the previous data will be deleted. If Recon is chosen then the images will be added to the dataset's recons list. For "simple" datasets that do not have Projections, Flat Before, etc there is only the option of adding additional stacks or recons. Moving Data *********** Data can also be moved from one dataset to another, or one stack type to another, by right-clicking the stack you wish to move and choosing the Move Stack option. .. image:: ../../_static/move_stack.png :alt: Dataset tree view Deleting Data ************* Deleting data can also be achieved by right-clicking on the dataset tree view. This can be used to delete individual stacks as well as entire datasets. .. image:: ../../_static/delete_data.png :alt: Deleting data in the tree view