For developers¶
Contributing¶
NiFreeze is a project of the NiPreps Community, which specifies the contributing guidelines. Before delving into the code, please make sure you have read all the guidelines offered online.
Documentation¶
Documentation sources are found under the docs/ folder, and builds are archived in the gh-pages branch of the repository.
With GitHub Pages, the documentation is posted under https://www.nipreps.org/nifreeze.
We maintain versioned documentation, by storing git tags under <major>.<minor>/ folders, i.e., we do not archive every patch release, but only every minor release.
In other words, folder 0.1/ of the documentation tree contains the documents for the latest release within the 0.1.x series.
With every commit (or merge commit) to main, the development version of the documentation under the folder main/ is updated too.
The gh-pages branch is automatically maintained with a GitHub Action.
Please, do not commit manually to gh-pages.
To build the documentation locally, you first need to make sure that setuptools_scm[toml] >= 6.2 is installed in your environment and then:
cd <nifreeze-repository>/
python -m setuptools_scm # This will generate ``src/nifreeze/_version.py``
make -C docs/ html
Benchmarking¶
NiFreeze uses asv for performance benchmarking. Benchmarking code is found under the
benchmarks/ folder. Maintaining reasonable runtime and memory consumption of core
NiFreeze components (e.g., models, data I/O, estimator) is critical for the
efficiency of pipelines using it.
The benchmarks measure the memory that operations allocate, their peak resident memory,
their CPU time and their wall time.
Every pull request is benchmarked together with the tip of main in the same job,
and fails if it makes a benchmark regress past the threshold of its kind;
the job summary lists every result.
The results of each commit to main are published in the nifreeze dashboard.
benchmarks/README.rst describes the thresholds, how to run the benchmarks locally,
and how to write new ones.
End-to-end tests¶
test/test_e2e_motion.py moves every diffusion-weighted volume of DIPY’s
Sherbrooke dataset by a known random rigid transform, runs the command line with
several models, and compares the estimated motion with the ground truth.
These tests are deselected by default; they need ANTs and run with:
pytest -m e2e test/test_e2e_motion.py
The End-to-end tests workflow runs them weekly, on demand, and on pull requests that change them, and lists the errors of every model in its job summary.
Library API (application program interface)¶
Information on specific functions, classes, and methods.
- nifreeze.analysis package
- Submodules
- nifreeze.analysis.filtering module
- nifreeze.analysis.measure_agreement module
- nifreeze.analysis.motion module
- nifreeze.analysis.phantoms module
- nifreeze.analysis.sensitivity module
- nifreeze.analysis.similarity module
- Submodules
- nifreeze.cli package
- nifreeze.data package
load()- Subpackages
- nifreeze.data.dmri package
- dMRI data representation
DWIfrom_nii()- Submodules
- nifreeze.data.dmri.base module
- nifreeze.data.dmri.io module
- nifreeze.data.dmri.utils module
DEFAULT_GRADIENT_ATOLDEFAULT_HIGHB_THRESHOLDDEFAULT_LOWB_THRESHOLDDEFAULT_MAX_S0DEFAULT_MIN_S0DEFAULT_MULTISHELL_BIN_COUNT_THRDEFAULT_NUM_BINSDTI_MIN_ORIENTATIONSGRADIENT_ABSENCE_ERROR_MSGGRADIENT_EXPECTED_COLUMNS_ERROR_MSGGRADIENT_NDIM_ERROR_MSGGRADIENT_OBJECT_ERROR_MSGGRADIENT_VOLUME_DIMENSIONALITY_MISMATCH_ERRORfind_shelling_scheme()format_gradients()transform_fsl_bvec()
- nifreeze.data.pet package
- PET data representation
PETfrom_nii()- Submodules
- nifreeze.data.pet.base module
- nifreeze.data.pet.io module
- nifreeze.data.pet.utils module
- nifreeze.data.dmri package
- Submodules
- nifreeze.data.base module
AFFINE_ABSENCE_ERROR_MSGAFFINE_NDIM_ERROR_MSGAFFINE_OBJECT_ERROR_MSGAFFINE_SHAPE_ERROR_MSGBRAINMASK_SHAPE_MISMATCH_ERROR_MSGBaseDatasetBaseDataset.__len__()BaseDataset.affineBaseDataset.brainmaskBaseDataset.datahdrBaseDataset.dataobjBaseDataset.from_filename()BaseDataset.get_filename()BaseDataset.motion_affinesBaseDataset.realign_into()BaseDataset.realigned()BaseDataset.set_transform()BaseDataset.shape3dBaseDataset.size3dBaseDataset.to_filename()BaseDataset.to_nifti()
DATAOBJ_ABSENCE_ERROR_MSGDATAOBJ_NDIM_ERROR_MSGDATAOBJ_OBJECT_ERROR_MSGImageGridto_nifti()validate_affine()validate_dataobj()
- nifreeze.data.filtering module
BVAL_ATOLCLIPPING_DEGENERATE_RANGE_ERROR_MSGCLIPPING_EMPTY_SELECTION_ERROR_MSGCLIPPING_INVALID_THRESHOLDS_ERROR_MSGCLIPPING_NONFINITE_THRESHOLDS_ERROR_MSGClippingValueErrorDEFAULT_CLIP_PERCENTILEDEFAULT_DTYPEadvanced_clip()dwi_select_shells()grand_mean_normalization()robust_minmax_normalization()robust_window()
- nifreeze.data.splitting module
- nifreeze.data.utils module
- nifreeze.data.base module
- nifreeze.estimator module
- nifreeze.exceptions module
- nifreeze.model package
AverageDWIModelBSplinePETModelDKIModelDTIModelExpectationModelGPLOOModelGPModelGQIKRRModelModelFactoryTrivialModel- Submodules
- nifreeze.model.base module
- nifreeze.model.dki module
- nifreeze.model.dmri module
- nifreeze.model.gpr module
- nifreeze.model.gqi module
- nifreeze.model.lovo module
- nifreeze.model.pet module
- nifreeze.registration package
- nifreeze.testing package
- Submodules
- nifreeze.testing.perturbations module
- nifreeze.testing.phantoms module
- nifreeze.testing.simulations module
BOUNDS_2FIBERS_DOMINANT_VF1BOUNDS_2FIBERS_NONDOMINANT_VF1BOUNDS_3FIBERS_VF1BOUNDS_3FIBERS_VF2BOUNDS_LAMBDA1BOUNDS_LAMBDA23add_b0()compute_pet_noise_sd()create_diffusion_encoding_gradient_dirs()create_random_diffusivity_eigenvalues()create_random_polar_angles()create_random_polar_coordinates()create_single_fiber_evecs()create_single_shell_gradient_table()create_three_fiber_random_volume_fractions()create_two_fiber_dominant_random_volume_fractions()create_two_fiber_nondominant_random_volume_fractions()get_query_vectors()group_values()serialize_dmri()serialize_dwi()serialize_gtab()simulate_multifiber_voxels()simulate_one_fiber_multivoxel()simulate_three_fiber_multivoxel()simulate_two_fiber_multivoxel()simulate_voxels()single_fiber_voxel()srtm()
- Submodules
- nifreeze.utils package
- Submodules
- nifreeze.utils.iterators module
BVALS_KWARGDEFAULT_ROUND_DECIMALSITERATOR_MULTIPLICITY_ERROR_MSGITERATOR_SIZE_ERROR_MSGMODALITY_SPECIFIC_SIZE_KEYSSIZE_KEYSSIZE_KWARGSTART_INDEX_DATA_LENGTH_ERROR_MSGSTART_INDEX_KWARGSTART_INDEX_POSITIVITY_ERROR_MSGSTOP_INDEX_DATA_LENGTH_ERROR_MSGSTOP_INDEX_KWARGSTOP_INDEX_ORDERING_ERROR_MSGUPTAKE_KWARGcentralsym_iterator()linear_iterator()monotonic_value_iterator()random_iterator()
- nifreeze.utils.ndimage module
- nifreeze.utils.iterators module
- Submodules
- nifreeze.viz package