PennSIVE pipelines
Generally we use R and develop R packages, but many of our tools have python and command-line interfaces as well.
If you’re building a package that uses a PennSIVE tool, or need to fine-tune parameters not exposed by the wrappers, you’re best off using the R package. If you’re using python you can use a rpy2-based wrapper and be able to keep parameters that represent NIFTI images in memory. If you’re building a neuroimaging pipeline in python with Nipype, we have a fork with our tools called PennSIVEpype. Otherwise, it’s best to use the command-line wrappers.
MIMoSA
MIMoSA automates multiple sclerosis (MS) lesion segmentation with just a T1w and FLAIR required.
Available as a BIDS app, on docker hub. For example:
# singularity pull docker://pennsive/mimosa
singularity run --cleanenv --bind ${PWD} --bind ${TMPDIR} \
\
/path/to/image \
inputs/data \
outputs \
participant --participant_label $sub_num \
--strip mass \
--n4 \
--register \
--whitestripe \
--thresh 0.25 \
--debug \
--skip_bids_validator
To use as a datalad bootstrap:
curl -LO https://raw.githubusercontent.com/PennLINC/TheWay/main/scripts/pmacs/bootstrap-mimosa.sh
bash bootstrap-mimosa.sh --bids-input ria+file:///path/to/bids --container-ds /path/or/uri/to/containers
cd mimosa/analysis
bash code/bsub_calls.sh
# when jobs complete
bash code/merge_outputs.sh
If your data are not in BIDS it’s possible to run the CLI of mimosa directly on a T1/FLAIR pair by using docker run --entrypoint=""
instead docker run
or singularity exec
instead of singularity run
and then calling /run.R directly. For example:
singularity exec --cleanenv --bind ${PWD} --bind ${TMPDIR} \
\
/path/to/image /run.R -i /path/to/folder/with/niftis \
-o /path/to/outdir \
-f flair.nii.gz \
-t t1.nii.gz \
-s mass \
--n4 \
--whitestripe
As a nipype interface:
from nipype.interfaces.mimosa import MIMoSA
= MIMoSA()
mimosa = "sub-01_mimosa-0.3.0/mimosa/t1_ws.nii.gz"
mimosa.inputs.t1 = "sub-01_mimosa-0.3.0/mimosa/flair_ws.nii.gz"
mimosa.inputs.flair = True
mimosa.inputs.tissue = True
mimosa.inputs.verbose = 1
mimosa.inputs.cores mimosa.run()
CVS
The central vein sign (CVS) uses a lesion probability map (from MIMoSA) and a vessellness filtering process to find veins running through lesions, biomarker of MS.
Available as a BIDS app, on docker hub. For example:
singularity run --cleanenv --bind ${PWD} --bind ${TMPDIR} \
\
/path/to/image \
inputs/data \
outputs \
participant --participant_label $sub_num \
--skullstrip \
--n4 \
--thresh 0.25 \
--skip_bids_validator
As a nipype interface:
from nipype.interfaces.cvs import CVS
= CVS()
cvs = "t1.nii.gz"
cvs.inputs.t1 = "flair.nii.gz"
cvs.inputs.flair = "epi.nii.gz"
cvs.inputs.epi = "mimosa_prob_map.nii.gz"
cvs.inputs.mimosa_prob_map = "mimosa_bin_map.nii.gz"
cvs.inputs.mimosa_bin_map = "candidate_lesions.npy"
cvs.inputs.candidate_lesions = "prob_map.npy"
cvs.inputs.cvs_prob_map = "biomarker.npy"
cvs.inputs.biomarker = False
cvs.inputs.parallel = True
cvs.inputs.skullstripped = True
cvs.inputs.biascorrected = True
cvs.inputs.c3d = 1
cvs.inputs.cores cvs.run()
PRL
The presence of paramagnetic rims around lesions (PRL) is another MS biomarker.
Available as a BIDS app, on docker hub. For example:
singularity run --cleanenv --bind ${PWD} --bind ${TMPDIR} \
\
/path/to/image \
inputs/data \
outputs \
participant --participant_label $sub_num
As a nipype interface:
from nipype.interfaces.prls import PRL
= PRL()
prl = "prob_map.nii.gz"
prl.inputs.prob_map = "lesion_map.nii.gz"
prl.inputs.lesion_map = "phase.nii.gz"
prl.inputs.phase = True
prl.inputs.disc prl.run()
Center detection
From the lesiontools package, the lesion center detection method helps count distinct lesions.
Available as a BIDS app, on docker hub. For example:
singularity run --cleanenv --bind ${PWD} --bind ${TMPDIR} \
\
/path/to/image \
inputs/data \
outputs \
participant --participant_label $sub_num \
--strip mass \
--n4 \
--min-center-size 10 \
--gmm \
--skip_bids_validator
As a nipype interface:
from nipype.interfaces.lesionclusters import LesionClusters
= LesionClusters()
clusters = "prob_map.nii.gz"
clusters.inputs.prob_map = "bin_map.nii.gz"
clusters.inputs.bin_map = "centers.nii.gz"
clusters.inputs.centers = "nnmap.nii.gz"
clusters.inputs.nnmap = "clusmap.nii.gz"
clusters.inputs.clusmap = "gmmmap.nii.gz"
clusters.inputs.gmmmap = True
clusters.inputs.gmm = True
clusters.inputs.parallel = 4
clusters.inputs.cores = 1.2
clusters.inputs.smooth = 10
clusters.inputs.min_center_size clusters.run()