mobie / mobie-utils-python

Python tools for MoBIE
MIT License
9 stars 5 forks source link

Build Status Anaconda-Server Badge

mobie-utils-python

A python library to generate projects for MoBIE.

Installation

From conda:

$ conda install -c conda-forge mobie_utils

For development:

You can set up (and activate) a conda environment with all dependencies from environment.yaml:

$ conda env create -f environment.yaml
$ conda activate mobie

and install the library via

$ pip install -e .

Usage

The library contains functionality to generate MoBIE projects, add data to it and create complex views. For complete examples, please check out the examples:

Below is a short code snippet that shows how to use it in a python script.

import mobie

# root folder for the mobie project
mobie_root = "/path/to/project-datasets/data"
# name of the dataset to be added
dataset_name = "my_dataset"

# file path and key for the input data
# key can be an internal path for hdf5 or zarr/n5 containers
# or a file pattern for image stacks
data_path = "/path/to/input_data.h5"
data_key = "/internal/h5/path"

# resolution of this initial data (in micrometer), chunks size and factors for downscaling
resolution = (.5, .25, .25)
chunks = (64, 128, 128)
scale_factors = [[1, 2, 2], [2, 2, 2], [2, 2, 2]]

mobie.add_image(data_path, data_key,
                mobie_root, dataset_name, image_name,
                resolution, chunks, scale_factors)

From the command line

The package also installs some command line scripts that can create MoBIE projects, add data to it and more:

Run <COMMAND-NAME> --help to get more information on how to use them.

Updating MoBIE projects

This library also provides functionality to update MoBIE projects to new specification versions. Updating is performed with the command line function mobie.migrate_project. Its only mandatory argument is the filepat to the project data:

mobie.migrate_project data

Warning: this command will update the metadata files without creating backups. You should either run this on projects within git, or create a manual backup of your project.

The most recent update is from version 0.2.1 to 0.3.0. Previous version updates can be performed by passing the -v flag to the migrate_project command.

As most likely the specs for the project metadata files change during an update, you need to purge the cached specs files by deleting them in the .mobie folder in your $HOME directory.

Citation

If you use the MoBIE framework in your research, please cite the MoBIE publication.