Index ND2 files¶
This command line tool indexes ND2 files in a specified directory and extracts basic metadata:
The script also supports filtering, sorting, and output formatting (table, csv, json).
As an example, the following command indexes ND2 files in the current directory, keeps selected columns, and filters images with width greater than 1000 pixels:
Output:
+-----------------------------+----------+----------------+--------------+
| Name | Size | Experiment | Resolution |
+-----------------------------+----------+----------------+--------------+
| 1 dfm tub pc.nd2 | 164.1 MB | Z (54) | 1024 x 512 |
| convallaria_FLIM.nd2 | 6.3 GB | XY (25), Z (5) | 1024 x 1024 |
| golgi01.nd2 | 60.4 MB | Z (24) | 1280 x 1024 |
| underwater_bmx.nd2 | 2.5 MB | | 1076 x 773 |
+-----------------------------+----------+----------------+--------------+
Arguments¶
Important
Arguments highlighted in bold (paths) are required.
-
pathsOne or more paths to ND2 files or directories containing ND2 files. Required.
-
--recurse,-rRecursively search directories for ND2 files. Optional.
-
--glob-pattern <pattern>,-g <pattern>Glob pattern to search for ND2 files. Default:
*.nd2. Optional. -
--sort-by <column>,-s <column>Column to sort by. Choices are valid column names, or append a hyphen (
-) for reverse order. If not specified, order is not guaranteed. Optional. -
--format <format>,-f <format>Output format. Choices:
table,csv,json. Default:table(if rich is available), otherwisejson. Optional. -
--include <list>,-i <list>Comma-separated list of columns to add to the default output. Optional.
-
--columns <list>,-c <list>Exact comma-separated list of columns to output (replaces default column selection). Optional.
-
--exclude <list>,-e <list>Comma-separated list of columns to remove from the selected output columns. Optional.
-
--all-columnsShow all columns by default (instead of hiding selected columns). Optional.
-
--no-headerDo not write the CSV header. Optional.
-
--filter <expression>,-F <expression>Filter the output using a Python expression (string) that evaluates to True or False for each row. Can be used multiple times. Example:
"Frames > 50 and 'T' in Experiment". Optional.
Valid column names¶
The following columns are available for output, filtering, and sorting.
| Column | Data Type | Description |
|---|---|---|
Path |
str |
Full file path |
Name |
str |
File name |
Version |
str |
ND2 file version |
Size |
str |
File size |
Modified |
str |
Last modified timestamp |
Experiment |
str |
Experiment names and frame count |
Frames |
int |
Total number of frames |
Dtype |
str |
Data type |
Bits |
int |
Bit depth |
Compression |
str |
Compression mode and parameter |
Resolution |
str |
Image resolution |
Channels |
int |
Number of channels |
Binary |
str |
Binary metadata |
Downsampled |
str |
Downsampled pyramid information |
Software |
str |
Acquisition software |
Grabber |
str |
Acquisition hardware/grabber |
Default output hides: Compression, Downsampled, Software, Grabber.
Examples¶
Here are some example usages of the limnd2-index command: