Skip to content

Customisation

Fraser Callaghan edited this page Feb 27, 2024 · 2 revisions

Configuration files

miresearch makes use of configuration (*.conf) files for customisation.

One can use multiple conf files and may even pass a conf file as a commandline argument for "codefree" manipulation.

miresearch looks for conf files at:

os.path.join(rootDir,'miresearch.conf'), # this is the default 'miresearch.conf' included at installation
os.path.join(os.path.expanduser("~"),'miresearch.conf'),
os.path.join(os.path.expanduser("~"),'.'+'miresearch.conf'), 
os.path.join(os.path.expanduser("~"), '.config','miresearch.conf'),
os.environ.get("MIRESEARCH_CONF", '')

The default 'miresearch.conf' file looks like this:

[DEFAULT]
debug=False

data_root_dir=
subject_prefix = 

# Choose: HARD, SOFT, NONE
anon_level = NONE

class_path = 
stable_directory_age_sec=60
directories = [["RAW", "DICOM"], "META"]

[app]
# Override DEFAULT parameters here

[parameters]
# Add application specific parameters here

Important features to take note of:

  • class_path Can point to a custom class that subclasses mi_subject.AbstractSubject
    • this should be formed like this: my_module.mySubClass
      • my_module is a my_module.py file found in your PYTHONPATH
      • mySubClass is the custom class, found in the my_module.py file, which subclasses mi_subject.AbstractSubject
  • Anything under parameters will be save to a dictionary for use within your mySubClass
    • To use:
      • add the following import statement to your my_module.py file:
        • from miresearch.mi_config import MIResearch_config
      • add your variables to one of the 'miresearch.conf' files listed above (or to a .conf file you pass in as a commandline option) see custom conf file below
      • access your variables:
        • MIResearch_config.parameters[extra_data_path]
        • NOTE the MIResearch_config.parameters dictionary will also contain all default parameters and their default values.

A basic, yet complete, example customisation is seen below with a custom subclass and a custom conf file.

In addition a linux systemd service file is included systemd service for miresearch.

Note: not only does the custom subclass override methods from the mi_subject.AbstractSubject parent class, it also adds additional options to the commandline interface provided by mirsearch.

Custom Subclass

Following is a custom subclass of mi_subject.AbstractSubject . Full functionality is not filled out but basic potential is described.

Custom CONF file

[parameters]
storage_path = /path/to/storage/
extra_data_path = /path/to/data/

Clone this wiki locally