Skip to content

drim2p

A dreamy 2-photon imaging processing pipeline.

Args: verbosity (int, optional): Verbosity level. Level 0 is INFO (default). Level 1 is DEBUG. quietness (int, optional): Quietness level. Level 0 suppresses INFO messages. Level 1 suppresses WARNING messages. no_colour (bool, optional): Whether to disable logging colours.

Usage:

drim2p [OPTIONS] COMMAND [ARGS]...

Options:

  -v, --verbose  Set verbosity level. Level 0 is INFO (default). Level 1 is
                 DEBUG.
  -q, --quiet    Suppress log output. One '--quiet' suppresses INFO messages.
                 Two '--quiet' and up suppresses WARNING messages.This
                 overrides verbosity set using '--verbose'.
  --no-colour    Disable logging colours.
  --help         Show this message and exit.

Subcommands

  • convert: Converts data to HDF5/NWB.
  • deltaf: Computes ΔF/F₀ for extracted signals.
  • draw: Allows for drawing ROIs on HDF5 dataset.
  • extract: Extracts signals.
  • motion: Handles motion correction.

drim2p convert

Converts data to HDF5/NWB.

Usage:

drim2p convert [OPTIONS] COMMAND [ARGS]...

Options:

  --help  Show this message and exit.

Subcommands

  • raw: Converts RAW data and metadata to HDF5.

drim2p convert raw

Converts RAW data and metadata to HDF5.

Note that SOURCE can be either a single file or a directory. If it is a directory, all the RAW files it contains will be converted.

If '--ini-path' is not provided, it will default to the same path as the source file with the extension changed to '.ini'. If '--xml-path' is not provided, it will default to the same path as the source file with the extension changed to '.xml', and the 'XYT' ending changed to 'OME'. Note the OME-XML path is optional if the INI file contains the OME-XML as an entry.

If generate_timestamps is set, a .notes.txt file with the same name as the RAW file should also be present.

Usage:

drim2p convert raw [OPTIONS] [SOURCE]

Options:

  --ini-path FILE               Path to the INI file containing metadata about
                                SOURCE. This is ignored if SOURCE is a
                                directory.
  --xml-path FILE               Path to the OME-XML file containing metadata
                                about SOURCE. This is ignored if SOURCE is a
                                directory.
  -o, --out DIRECTORY           Output directory in which to put the converted
                                files. Default is to output in the same
                                directory as SOURCE.
  -r, --recursive               Whether to search directories recursively when
                                looking for RAW files.
  -i, --include TEXT            Include filters to apply when searching for
                                RAW files. This supports regular-expressions.
                                Include filters are applied before any exclude
                                filters.
  -e, --exclude TEXT            Exclude filters to apply when searching for
                                RAW files. This supports regular-expressions.
                                Exclude filters are applied after all include
                                filters.
  -c, --compression [gzip|lzf]  Compression algorithm to use.
  --aggression INTEGER RANGE    Aggression level to use for GZIP compression.
                                Lower means faster/worse compression, higher
                                means slower/better compression. Ignored if '
                                --compression' is not GZIP.  [0<=x<=9]
  --generate-timestamps         Whether to generate timestamps from the notes
                                entries of the RAW files.
  --force                       Whether to overwrite output files if they
                                exist.
  --help                        Show this message and exit.

drim2p deltaf

Computes ΔF/F₀ for extracted signals.

Input arrays should be 1- or 2D arrays, where the first dimension is the one along which to compute f₀.

If given a rolling window width, f₀ is computed for each entry along the first dimension of the input array. For values around the edges (within half of window width), the array is padded using the provided method (default is padding with 0s). Because of this, choosing a window that is too large can produce some unexpected values far into the array.

Usage:

drim2p deltaf [OPTIONS] [SOURCE]

Options:

  -m, --method [percentile|mean|median]
                                  Computation method for f₀.
  -p, --percentile INTEGER        Percentile to use when computing f₀ using
                                  the 'percentile' method. Ignored if
                                  computing with a different method.
  -w, --window-width INTEGER      Rolling window width in frames to use when
                                  computing f₀. Pass 0 to disable it
                                  (default). If greater than 0, the window is
                                  used to compute a running value of f₀ for
                                  each timepoint of the input, with padding
                                  applied according to '--padding' around the
                                  edges. If greater than 0, the rolling window
                                  should be less than twice the size of the
                                  first dimension of the input minus 1.
  --padding [constant|reflect|wrap|edge]
                                  Mode to use when padding the input. Ignored
                                  if '--window-width' is 0.
  --padding-value INTEGER         Constant value to use when padding using
                                  'constant' mode. Ignored if '--padding' is
                                  not 'constant'.
  -r, --recursive                 Whether to search directories recursively
                                  when looking for files.
  -i, --include TEXT              Include filters to apply when searching for
                                  files. This supports regular expressions.
                                  Include filters are applied before any
                                  exclude filters. They should be a semi-
                                  colon-separated string of filters (e.g.,
                                  'foo;bar' contains two filters, 'foo' and
                                  'bar').
  -e, --exclude TEXT              Exclude filters to apply when searching for
                                  files. This supports regular expressions.
                                  Exclude filters are applied after all
                                  include filters. They should be a semi-
                                  colon-separated string of filters (e.g.,
                                  'foo;bar' contains two filters, 'foo' and
                                  'bar').
  --force                         Whether to overwrite output files if they
                                  exist.
  --help                          Show this message and exit.

drim2p draw

Allows for drawing ROIs on HDF5 dataset.

Usage:

drim2p draw [OPTIONS] COMMAND [ARGS]...

Options:

  --help  Show this message and exit.

Subcommands

  • roi: Starts a napari GUI to draw ROIs on HDF5 datasets.

drim2p draw roi

Starts a napari GUI to draw ROIs on HDF5 datasets.

Note that SOURCE can be either a single file or a directory. If it is a directory, all the HDF5 files it contains will be queued for ROI drawing.

Usage:

drim2p draw roi [OPTIONS] [SOURCE]

Options:

  -t, --template FILE             Path to the HDF5 file to read default ROIs
                                  from. When provided, any ROIs already
                                  present in the file will be used as the
                                  default ROIs for all SOURCE file. Use in
                                  conjunction with '--force' to overwrite any
                                  existing ROIs with the template ones.
  -d, --dataset TEXT              Name of the HDF5 dataset to display for ROI
                                  drawing.
  -w, --projection-window INTEGER
                                  Window size to use for grouped Z
                                  projections.
  -r, --recursive                 Whether to search directories recursively
                                  when looking for HDF5 files.
  -i, --include TEXT              Include filters to apply when searching for
                                  HDF5 files. This supports regular-
                                  expressions. Include filters are applied
                                  before any exclude filters.
  -e, --exclude TEXT              Exclude filters to apply when searching for
                                  HDF5 files. This supports regular-
                                  expressions. Exclude filters are applied
                                  after all include filters.
  --lazy                          Whether to lazily load the file. This will
                                  speed up the GUI startup time but will slow
                                  down any slicing when it is open. This will
                                  also disable themean intensity projection.
  --force                         Whether to ovewrite ROIs if some are found
                                  in SOURCE. Otherwise, ROIs are appended. Be
                                  careful when using this option as it will
                                  lead to all ROIs being deleted when opening
                                  a file.
  --help                          Show this message and exit.

drim2p extract

Extracts signals.

Usage:

drim2p extract [OPTIONS] COMMAND [ARGS]...

Options:

  --help  Show this message and exit.

Subcommands

  • signal: Extracts decontaminated signals from ROIs.

drim2p extract signal

Extracts decontaminated signals from ROIs.

Note that SOURCE can be either a single file or a directory. If it is a directory, all the HDF5 files it contains will be converted.

By default, all provided files are treated as separate sessions. In order to process files together, use 'group-by-regex' to group paths together based on a regular expression. If you wish to group all files together, pass an empty string as the regular expression.

Usage:

drim2p extract signal [OPTIONS] [SOURCE]

Options:

  --group-by-regex TEXT         Regular expression to use when grouping
                                SOURCEs together. This results in the paths
                                being preprocessed together based on the
                                regex. This is ignored if SOURCE is a single
                                file. Note that using this can lead to a very
                                high memory usage depending on how many chunks
                                needs to be loaded. Also note that for
                                grouping to work, grouped files should have
                                the same number of ROIs.
  -d, --dataset TEXT            Name of the HDF5 dataset to display for ROI
                                drawing.
  -r, --recursive               Whether to search directories recursively when
                                looking for HDF5 files.
  -i, --include TEXT            Include filters to apply when searching for
                                HDF5 files. This supports regular-expressions.
                                Include filters are applied before any exclude
                                filters.
  -e, --exclude TEXT            Exclude filters to apply when searching for
                                HDF5 files. This supports regular-expressions.
                                Exclude filters are applied after all include
                                filters.
  --dont-abort-on-skipped-file  Whether to keep working on a group if one or
                                more of its files is skipped for any reason
                                (e.g., file was already preprocessed by '--
                                force' is not set).
  --force                       Whether to overwrite output files if they
                                exist.
  --help                        Show this message and exit.

drim2p motion

Handles motion correction.

Usage:

drim2p motion [OPTIONS] COMMAND [ARGS]...

Options:

  --help  Show this message and exit.

Subcommands

  • correct: Applies motion correction on HDF5 chunks.

drim2p motion correct

Applies motion correction on HDF5 chunks.

The motion correction is configured through a TOML settings file (available from the source code in the resources directory). The file allows customising behaviour such as the strategy to use or the maximum displacement allowed.

Usage:

drim2p motion correct [OPTIONS] [SOURCE]

Options:

  -s, --settings-path FILE      Path to the settings file to use.
  -r, --recursive               Whether to search directories recursively when
                                looking for RAW files.
  -i, --include TEXT            Include filters to apply when searching for
                                RAW files. This supports regular-expressions.
                                Include filters are applied before any exclude
                                filters.
  -e, --exclude TEXT            Exclude filters to apply when searching for
                                RAW files. This supports regular-expressions.
                                Exclude filters are applied after all include
                                filters.
  -c, --compression [gzip|lzf]  Compression algorithm to use.
  --aggression INTEGER RANGE    Aggression level to use for GZIP compression.
                                Lower means faster/worse compression, higher
                                means slower/better compression. Ignored if '
                                --compression' is not GZIP.  [0<=x<=9]
  --force                       Whether to overwrite output datasets if they
                                exist.
  --help                        Show this message and exit.