Code Monkey home page Code Monkey logo

pumi's Introduction

PUMI

Laboratory for Predictive Neuroimaging - University Hospital Essen, Germany

Open in GitHub Codespaces

Status

GitHub GitHub repo size GitHub last commit GitHub Workflow Status GitHub tag (latest by date) GitHub release (latest by date)

Docker

Docker Image Version (latest semver) Docker Image Size (latest semver)

Docker Image Version (latest semver) Docker Image Size (latest semver)

Issues

GitHub issues GitHub closed issues

First steps for developers

Clone this repo locally

git clone [email protected]:pni-lab/PUMI.git

Set up dependencies

Option A: Docker

  • pull the docker image:
    • pnilab/pumi-slim:latest: for a slim image containing the latest PUMI version and only the exact dependencies it needs
    • pnilab/pumi:latest: for the full image, containing all dependnecies but no PUMI source code (useful when integrating new tools, but takes long to download). To work in the full image:
    • - run it: `docker run -ti pnilab/pumi bash`
      - get the latest PUMI source by `git clone http://github.com/pni-lab/PUMI.git`
      - install PUMI: `cd /PUMI; pip install .`
      - 
      
  • set up your IDE to work within the container

Option B: Install all non-python dependencies locally

  • FSL
  • AFNI
  • ANTs
  • Freesurfer

Get test dataset (optional)

cd data_in
export WEBDAV_USERNAME=XXXX
export WEBDAV_PASSWORD=XXXX-XXXX-XXXX-XXXX
datalad install -s [email protected]:pni-data/pumi_test_data.git pumi_test_data
datalad siblings -d pumi_test_data enable -s sciebo.sfb289
datalad get pumi_test_data/*

Contact the developers for webdav credentials.

Coding Conventions

  • name of workflow is the same as the name of the variable that holds it

  • name of node is the same as the name of the variable that holds it

  • qc nodes's name defines the subdir in qc; it should be: <base_wf>_qc

  • avoid "batch-connects" in @PumiPipeline funcions: it is preferred that right after node (or workflow) definition all possible connect statements corresponding to the node are specified

  • for readibility, we use the signature: connect(source_node, source_field, dest_node, dest_field)

  • except, in case there are multiple connections between the same pair of nodes, batch-connect should be used

  • @PumiPipeline funcions' first connect statement(s) is (are) connecting to the inputspec

  • @PumiPipeline funcions' last connect statement(s) is (are) connecting to the outputspec

  • @PumiPipeline funcions' are minimalistic and do NO "housekeeping".

Version incrementing rules

  • increment major if:
    • reverse-compatibility is broken
    • a substantial set of new features are added or a grand milestone is reached in the development
  • increment minor if:
    • the running environment must be changed, i.e. when the docker image pnilab/pumi has been changed
    • new feature is added (e.g. a new preprocessing step is integrated)
  • increment patch for smaller patches, e.g.:
    • changes in existing behavior (new parameter, params renamed)
    • bugfixes
    • typically after merging a pull request

Caution:

Reverse compatibility will not be guaranteed until the major version reaches 1

Incrementing major or minor version:

  • commit the changes
  • tag the commit, deploy the new full docker image locally, push the tag:
git tag <MAJOR>.<MINOR>.<PATCH>
./deploy_full.sh # creates the new full docker image
git push --tag
  • push to your branch
  • open PR A github action automatically creates the new slim docker image.

Incrementing patch version:

  • commit the changes
  • tag the commit, push the tag
git tag <MAJOR>.<MINOR>.<PATCH>
git push --tag
  • push to your branch
  • open PR A github action automatically creates the new slim docker image.

Cite

Nipype

  • Gorgolewski K, Burns CD, Madison C, Clark D, Halchenko YO, Waskom ML, Ghosh SS. (2011). Nipype: a flexible, lightweight and extensible neuroimaging data processing framework in Python. Front. Neuroinform. 5:13.

FSL

  • M.W. Woolrich, S. Jbabdi, B. Patenaude, M. Chappell, S. Makni, T. Behrens, C. Beckmann, M. Jenkinson, S.M. Smith. Bayesian analysis of neuroimaging data in FSL. NeuroImage, 45:S173-86, 2009

  • S.M. Smith, M. Jenkinson, M.W. Woolrich, C.F. Beckmann, T.E.J. Behrens, H. Johansen-Berg, P.R. Bannister, M. De Luca, I. Drobnjak, D.E. Flitney, R. Niazy, J. Saunders, J. Vickers, Y. Zhang, N. De Stefano, J.M. Brady, and P.M. Matthews. Advances in functional and structural MR image analysis and implementation as FSL. NeuroImage, 23(S1):208-19, 2004

  • M. Jenkinson, C.F. Beckmann, T.E. Behrens, M.W. Woolrich, S.M. Smith. FSL. NeuroImage, 62:782-90, 2012

ANTs

  • Tustison NJ, Cook PA, Klein A, Song G, Das SR, Duda JT, Kandel BM, van Strien N, Stone JR, Gee JC, Avants BB. Large-scale evaluation of ANTs and FreeSurfer cortical thickness measurements. Neuroimage. 2014 Oct 1;99:166-79. doi: 10.1016/j.neuroimage.2014.05.044. Epub 2014 May 29. PMID: 24879923.

  • Avants BB, Tustison NJ, Stauffer M, Song G, Wu B, Gee JC. The Insight ToolKit image registration framework. Front Neuroinform. 2014 Apr 28;8:44. doi: 10.3389/fninf.2014.00044. PMID: 24817849; PMCID: PMC4009425.

  • Avants BB, Tustison NJ, Wu J, Cook PA, Gee JC. An open source multivariate framework for n-tissue segmentation with evaluation on public data. Neuroinformatics. 2011 Dec;9(4):381-400. doi: 10.1007/s12021-011-9109-y. PMID: 21373993; PMCID: PMC3297199.

AFNI

  • Cox RW, Jesmanowicz A (1999). Real-time 3D image registration for functional MRI. Magnetic Resonance in Medicine, 42: 1014-1018.

  • Glen DR, Taylor PA, Buchsbaum BR, Cox RW, Reynolds RC (2020). Beware (Surprisingly Common) Left-Right Flips in Your MRI Data: An Efficient and Robust Method to Check MRI Dataset Consistency Using AFNI. Front. Neuroinformatics 14. doi.org/10.3389/fninf.2020.00018

  • Taylor PA, Chen G, Glen DR, Rajendra JK, Reynolds RC, Cox RW (2018). FMRI processing with AFNI: Some comments and corrections on ‘Exploring the Impact of Analysis Software on Task fMRI Results’. bioRxiv 308643; doi:10.1101/308643

  • Jo HJ, Saad ZS, Simmons WK, Milbury LA, Cox RW. Mapping sources of correlation in resting state FMRI, with artifact detection and removal. Neuroimage. 2010;52(2):571-582. doi:10.1016/j.neuroimage.2010.04.246

HD-BET

  • Isensee F, Schell M, Tursunova I, Brugnara G, Bonekamp D, Neuberger U, Wick A, Schlemmer HP, Heiland S, Wick W, Bendszus M, Maier-Hein KH, Kickingereder P. Automated brain extraction of multi-sequence MRI using artificial neural networks. Hum Brain Mapp. 2019; 1–13. https://doi.org/10.1002/hbm.24750

pydeface

  • Omer Faruk Gulban, Dylan Nielson, Russ Poldrack, john lee, Chris Gorgolewski, Vanessasaurus, & Satrajit Ghosh. (2019). poldracklab/pydeface: v2.0.0 (v2.0.0). Zenodo. https://doi.org/10.5281/zenodo.3524401

Templateflow

  • TemplateFlow: a community archive of imaging templates and atlases for improved consistency in neuroimaging R Ciric, R Lorenz, WH Thompson, M Goncalves, E MacNicol, CJ Markiewicz, YO Halchenko, SS Ghosh, KJ Gorgolewski, RA Poldrack, O Esteban bioRxiv 2021.02.10.430678; doi: 10.1101/2021.02.10.430678 =======

pumi's People

Contributors

englertr avatar khoffschlag avatar mberjano avatar mhmadabs avatar spisakt avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

pumi's Issues

output and QC sink folder naming template

OUTPUT SINK:
<sink_dir>/subject-//<source_entities>_.
ex:
pumi-results/sub-001/anat/sub-001_T1w_brain.nii.gz
pumi-results/sub-001/anat/sub-001_T1w_brain_mask.nii.gz
pumi-results/sub-002/func/sub-001_task-rest_bold_mc.nii.gz

suffix: always defined by the subworkflow (we might be able to re-define it)


QC SINK:
//<subworkflow_name>/<source_entities>_.

<source_entities>: must contain the subject id

ex:
qc/anat/bet/sub-001_T1w_brain.ppm
qc/anat/bet/sub-001_T1w_brain_mask.ppm
pumi-results/qc/func/mc/sub-001_task-rest_bold_mc_rot.png

test dockerfile

Check if the container created from the Dockerfile really works.
To do this, run a pipeline in the container.

qc-pipelines can only sink png files

The standard qc-pipeline regex substitution not only adjusts the path to the desired format, but also replaces the filename with 'sub-<subject_id>.png'.

It should be possible to sink other formats as well (i.e. the actual file extension should be catched and appended to the end)

core enhancement: default fields as workflow peoperties?

The decorated function gets access to a PUMI.NestedWorkflow instance, passed in the function signature as wf.

PUMI workflows accept "default" strings in some cases, like:

wf.connect('inputspec',` 'in_file', despike, 'in_file')

Let's discuss if it makes sense to accept wf.inputspec or pass inputspec as a function parameter instead.

This applies to outputspec and sinker, too.

add **kwargs

  • pass kwargs to most straightforward node constructor
  • If there is more than one straightforward option: pass multiple dicts that follow the convention <software_tool>_kwargs

BET node

only after the iterable vs. mapnode discussion

take the BET node from the old PUMI repo and "port" it to the new PUMI.
Adjust it based on the (possible) decision of using iterables instead if MapNodes for subjects.

revise QC.py sinking structure

Only do this after prior discussion

QC outputs needs to be sinked in a special structure to support easy quality inspection.

tweak fsl parameters

The brain extractions do not look outstanding.
The vertical gradient probably needs to be adjusted.

adapt code to new style convention

Only possible after the discussion about the style and naming convention

Adapt the code (especially for connecting the nodes and pipelines) to the new convention.

repo folder structure

We need the following dirs:

examples: example pipelines (the current mapnode and the iterable pipelines must be moved here), mostly for "education" purposes, or to be looked up during development
pipelines: here we will have a collection of the actual PUMI-based pipelines for "production" purposes (like RPN-signature)
scripts: any helper scripts, + later maybe a wrapper for the docker command that runs pumi-pipelines

fix Dockerfile

There are some problems with the Dockerfile, especially if you want to run PUMI in PyCharm with a docker remote interpreter.

Update Dockerfile

No longer use the latest software versions for FSL etc., instead use the versions with which we have tested PUMI.

Missing:

  • Templateflow
  • ANTs
  • HD-Bet
  • GPU support

BET with Functional Data

Run the bet_subworkflow on functional data and compare the results with the results of RPN-Signature

add porting-notes to the documentation

Notes on porting from the old PUMI version to the new one:
I will use the terms „NP“ for „new PUMI“ and „OP“ for „old PUMI“.

  • Use NP NestedNodes and NestedWorkflow instead of nipype nodes and workflows
    • You only have to change the nipype-node-import to from PUMI.engine import NestedNode as Node and the nipype-workflow-import to from PUMI.engine import NestedWorkflow as Workflow
  • Every workflow of NP must use a (suitable) decorator.
    • Anatomical related workflows use „AnatPipeline“, functional ones „FuncPipelines“ and QC-Workflows use „QcPipeline“
    • You have to specify the inputspec_fields and the outputspec_fields when using the decorator
    • It‘s possible to specify your own DataSinker regex-substitutions with regexp_sub=[]
    • You can deactivate the default regex substitutions with default_regexp_sub=False (not advised if you don‘t really know what you do)
    • Example usage with comments can seen here in https://github.com/pni-lab/PUMI/blob/main/PUMI/pipelines/anat/segmentation.py at the qc_bet definition
  • Don‘t create workflow objects in your NP workflow methods. The decorator will create a workflow object and you can access it simply via using „wf“.
    • Example: wf.connect('inputspec', 'in_file', plot, 'registered_brain')
  • Don‘t create inputspec, outputspec, and SinkDir objects in NP. The decorator will handle this.
    • You can utilize these in connect-statements by using the strings „inputspec“, „outputspec“ and „sinker“.
      • Example 1: wf.connect(bet, 'out_file', 'outputspec', 'out_file')
      • Example 2: wf.connect(bet, 'out_file', 'sinker', 'out_file')
    • The inputspec_fields that you specify in the decorator are the IdentityInterface fields of the inputspec object in OP
    • The outputspec_fields that you specify in the decorator are the IdentityInterface fields of the outputspec object in OP
  • The first parameter of you workflow has to be „wf“ and the last one „**kwargs“. You do not need to pass wf yourself, the decorator will handle this
  • Currently you have to pass "qc_dir=wf.qc_dir" when creating a qc object. We will fix this in the future. This can be seen in https://github.com/pni-lab/PUMI/blob/main/PUMI/pipelines/anat/segmentation.py in the bet_fsl workflow
  • Don‘t use MapNodes. Most times it‘s enough to change MapNode to Node and delete the iterfields but verify that this makes sense when doing it!
  • You may stumble across such connection statements in OP (note the „outputspec.[...]“ and „inputspec.[...]“): wf_mc.connect(mytmpfilt, 'outputspec.func_tmplfilt', fmri_qc_mc_dspk_nuis_bpf, 'inputspec.func').Don‘t explicitly mention inputspec/outputspec in NP when connecting nested workflows. The NP equivalent would be: wf_mc.connect(mytmpfilt, 'func_tmplfilt', fmri_qc_mc_dspk_nuis_bpf, 'func').

Also note the coding conventions mentioned in NP README (https://github.com/pni-lab/PUMI)

De-facing

A AnatPUMI pipeline that uses pydeface or similar to de-face an anatomical image.

  • get in touch with Balint to discuss which de-face software to use

  • create QC image (bet_wf)

  • create a test

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.