Guide to adding new experiment setups - galizia-lab/pyview GitHub Wiki

Step 1: Preparation

  1. Decide a value of LE_loadExp to use. See here for existing values.
  2. Add this value and a short description to the documentation of the flag here.
  3. 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)
  4. 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:

  1. Subclass "P1SingleWavelengthAbstract"
  2. Override the methods "get_extensions" and "read_data", for example, as in the classes P1SingleWavelengthTIF.
  3. Optionally, override the method "get_p1_metadata_from_filenames", for example, as in the class P1SingleWavelengthLSM

Dual Wavelength data in two separate files:

  1. Subclass "P1DualWavelengthTIFTwoFiles"
  2. Override the methods "get_extensions" and "read_data", for example, as in the class P1DualWavelengthTill.

Dual Wavelength data in a single file:

  1. Subclass "P1DualWavelengthTIFSingleFile"
  2. Override the methods "get_extensions" and "read_data"

Notes:

  1. 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:
    1. __init__: Please re-implement everything as in LSMImporter.__init__
    2. parse_metadata: See documentation string of this method in BaseImporter.
    3. get_animal_tag_raw_data_mapping: See documentation string of this method in BaseImporter.
    4. get_path_relative_to_data_dir: See documentation string of this method in BaseImporter.

[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:
    1. __init__: Please re-implement everything as in VIEWTIFFLoaderInterface.__init__
    2. refresh_layout: This methods refreshes the layout of GUI Tab that does the direct loading. See VIEWTIFFLoaderInterface.refresh_layout
    3. 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:

  1. view/python_core/p1_class/__init__.py/get_empty_p1: add the P1-class of your setup
  2. view.python_core.measurement_list.importers.get_importer_class: add the class for importing metadata of your setup
  3. [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!