Guide to adding new experiment setups - galizia-lab/pyview GitHub Wiki
Step 1: Preparation
- Decide a value of LE_loadExp to use. See here for existing values.
- Add this value and a short description to the documentation of the flag here.
- Also add the same to the column "Selectable Options" for the flag "LE_loadExp" in the file "view/flags_and_metadata_definitions/view_flags_definition.csv" (If you used MS-Excel/Libreoffice to edit the CSV file, please open the file after saving in a text editor and make sure the format is COMMA-separated. Sometimes, MS-Excel/Libreoffice saves data in TAB or SEMICOLON separated)
- Also add this entry to the setup definitions file "view/flags_and_metadata_definitions/setup_definitions.csv". Note that this file is used only by the direct load module of VIEW-GUI. (If you used MS-Excel/Libreoffice to edit the CSV file, please open the file after saving in a text editor and make sure the format is COMMA-separated. Sometimes, MS-Excel/Libreoffice saves data in TAB or SEMICOLON separated)
Step 2: Create new class for data (skip if an existing class works)
In the file "view/python_core/p1_class/__init__.py", create a new P1-class for your experimental setup. Depending on the format in which your data is stored, you have to subclass particular classes and override (re-implement) particular methods
Single Wavelength data:
- Subclass "P1SingleWavelengthAbstract"
- Override the methods "get_extensions" and "read_data", for example, as in the classes P1SingleWavelengthTIF.
- Optionally, override the method "get_p1_metadata_from_filenames", for example, as in the class P1SingleWavelengthLSM
Dual Wavelength data in two separate files:
- Subclass "P1DualWavelengthTIFTwoFiles"
- Override the methods "get_extensions" and "read_data", for example, as in the class P1DualWavelengthTill.
Dual Wavelength data in a single file:
- Subclass "P1DualWavelengthTIFSingleFile"
- Override the methods "get_extensions" and "read_data"
Notes:
- Please pay attention to the documentation strings of the methods you are overriding. Methods having the same name might have slightly different return values. E.g.: The method "read_data" of "P1SingleWavelengthAbstract" and "P1DualWavelengthTIFTwoFiles" takes a single filename and returns a single numpy ndarray of format XYT containing raw data. In contrast, the method "read_data" of "P1DualWavelengthTIFSingleFile" takes a single filename and returns a tuple of two numpy ndarrays of format XYT, for 340nm and 380nm data.
Step 3: Create a new class for importing your metadata (skip if an existing class works)
In the file "view/python_core/measurement_list/importers.py", create a new class for importing your metadata.
- We already have some classes for importing metadata from TillVision setups (
TillImporterTwoWavelength
,TillImporterOneWavelength
) and from LSM510 (LSMImporter
). Have a look at them. - You need to create a subclass of
BaseImporter
and override/re-implement the following methods:__init__
: Please re-implement everything as inLSMImporter.__init__
parse_metadata
: See documentation string of this method inBaseImporter
.get_animal_tag_raw_data_mapping
: See documentation string of this method inBaseImporter
.get_path_relative_to_data_dir
: See documentation string of this method inBaseImporter
.
[Optional] Step 3a: Create a new class for the "Direct Load" module of the GUI for your new setup
In the file "view/gui/direct_load.py", create a new "Interface" class for your setup.
- We already have some class for different setups (
VIEWTIFFLoaderInterface
,TillSingleLoaderInterface
,TillDualLoaderInterface
,ZeissSingleLoaderInterface
,OmeFuraTiffInterface
) - You need to create a subclass of
BaseLoaderInterface
and override/re-implement the following methods:__init__
: Please re-implement everything as inVIEWTIFFLoaderInterface.__init__
refresh_layout
: This methods refreshes the layout of GUI Tab that does the direct loading. SeeVIEWTIFFLoaderInterface.refresh_layout
get_p1_class
: Returns the "P1" class for your setup
Step 4:
Add the value of "LE_loadExp" for your setup to the if-else ladders to the following methods:
view/python_core/p1_class/__init__.py/get_empty_p1
: add the P1-class of your setupview.python_core.measurement_list.importers.get_importer_class
: add the class for importing metadata of your setup- [optional]
view.gui.direct_load.get_loader_interface_class
: add the "Interface" class for your setup created in Step 3 above.
Step 5:
Congrats, you are done!