Skip to content

Commit

Permalink
Merged conflicts dev-pgd-hk
Browse files Browse the repository at this point in the history
  • Loading branch information
pdedumast committed Oct 30, 2020
2 parents 2e0a8d0 + 2f3f15d commit 113fc84
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 4 deletions.
2 changes: 1 addition & 1 deletion documentation/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Prerequisites

$ firefox https://store.docker.com/editions/community/docker-ce-desktop-windows

.. note:: Connectome Mapper 3 BIDSApp has been tested only on Ubuntu and MacOSX. For Windows users, it might be required to make few patches in the Dockerfile.
.. note:: The MIALSRTK BIDSApp has been tested only on Ubuntu and MacOSX. For Windows users, it might be required to make few patches in the Dockerfile.


* Docker managed as a non-root user
Expand Down
77 changes: 74 additions & 3 deletions pymialsrtk/interfaces/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ class MultipleBtkNLMDenoising(BaseInterface):
See Also
--------
pymialsrtk.interfaces.preprocess.BtkNLMDenoising
"""

input_spec = MultipleBtkNLMDenoisingInputSpec
Expand Down Expand Up @@ -295,6 +294,16 @@ class MultipleMialsrtkCorrectSliceIntensityOutputSpec(TraitedSpec):


class MultipleMialsrtkCorrectSliceIntensity(BaseInterface):
"""
Runs the MIAL SRTK slice intensity correction module [to_be_cited] on multiple images.
Calls MialsrtkCorrectSliceIntensity interface with a list of images/masks.
See also
------------
pymialsrtk.interfaces.preprocess.MialsrtkCorrectSliceIntensity
"""

input_spec = MultipleMialsrtkCorrectSliceIntensityInputSpec
output_spec = MultipleMialsrtkCorrectSliceIntensityOutputSpec

Expand Down Expand Up @@ -420,6 +429,20 @@ class MultipleMialsrtkSliceBySliceN4BiasFieldCorrectionOutputSpec(TraitedSpec):


class MultipleMialsrtkSliceBySliceN4BiasFieldCorrection(BaseInterface):
"""
Runs on multiple images the MIAL SRTK slice by slice N4 bias field correction module that implements the method proposed by Tustison et al. [1]_.
Calls MialsrtkSliceBySliceN4BiasFieldCorrection interface with a list of images/masks.
See also
------------
pymialsrtk.interfaces.preprocess.MialsrtkSliceBySliceN4BiasFieldCorrection
References
------------
.. [1] Tustison et al.; Medical Imaging, IEEE Transactions, 2010. `(link to paper) <https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3071855>`_
"""

input_spec = MultipleMialsrtkSliceBySliceN4BiasFieldCorrectionInputSpec
output_spec = MultipleMialsrtkSliceBySliceN4BiasFieldCorrectionOutputSpec

Expand Down Expand Up @@ -484,6 +507,7 @@ class MialsrtkSliceBySliceCorrectBiasField(BaseInterface):
>>> biasFieldCorr.inputs.bids_dir = '/my_directory'
>>> biasFieldCorr.inputs.in_file = 'my_image.nii.gz'
>>> biasFieldCorr.inputs.in_mask = 'my_mask.nii.gz'
>>> biasFieldCorr.inputs.in_field = 'my_field.nii.gz'
>>> biasFieldCorr.inputs.out_im_postfix = '_bcorr'
>>> biasFieldCorr.run() # doctest: +SKIP
Expand Down Expand Up @@ -526,6 +550,16 @@ class MultipleMialsrtkSliceBySliceCorrectBiasFieldOutputSpec(TraitedSpec):


class MultipleMialsrtkSliceBySliceCorrectBiasField(BaseInterface):
"""
Runs the MIAL SRTK slice by slice bias field correction module [to_be_cited] on multiple images.
Calls MialsrtkSliceBySliceCorrectBiasField interface with a list of images/masks/fields.
See also
------------
pymialsrtk.interfaces.preprocess.MialsrtkCorrectSliceIntensity
"""

input_spec = MultipleMialsrtkSliceBySliceCorrectBiasFieldInputSpec
output_spec = MultipleMialsrtkSliceBySliceCorrectBiasFieldOutputSpec

Expand Down Expand Up @@ -779,6 +813,16 @@ class MultipleMialsrtkMaskImageOutputSpec(TraitedSpec):


class MultipleMialsrtkMaskImage(BaseInterface):
"""
Runs the MIAL SRTK mask image module on multiple images.
Calls MialsrtkMaskImage interface with a list of images/masks.
See also
------------
pymialsrtk.interfaces.preprocess.MialsrtkMaskImage
"""

input_spec = MultipleMialsrtkMaskImageInputSpec
output_spec = MultipleMialsrtkMaskImageOutputSpec

Expand Down Expand Up @@ -870,7 +914,18 @@ def _run_interface(self, runtime):
return runtime

def _extractBrain(self, dataPath, modelCkptLoc, thresholdLoc, modelCkptSeg, thresholdSeg, bidsDir, out_postfix):

"""
Generate a brain mask by passing the input image(s) through two networks:
The first network localizes the brain by a coarse-grained segmentation while the
second one segments it more precisely. The function saves the output mask in the
specific module folder created in bidsDir
Parameters
----------
Described in pymialsrtk.interfaces.preprocess.BrainExtractionInputSpec
"""

# Step1: Main part brain localization
normalize = "local_max"
width = 128
Expand Down Expand Up @@ -1101,7 +1156,7 @@ def _extractBrain(self, dataPath, modelCkptLoc, thresholdLoc, modelCkptSeg, thre
pred3d = np.asarray(pred3d)
upsampled = np.swapaxes(np.swapaxes(pred3d,1,2),0,2) #if Orient module applied, no need for this line(?)
up_mask = nibabel.Nifti1Image(upsampled,img_nib.affine)
# Save
# Save output mask
_, name, ext = split_filename(os.path.abspath(dataPath))
save_file = os.path.join(os.getcwd().replace(bidsDir, '/fetaldata'), ''.join((name, out_postfix, ext)))
nibabel.save(up_mask, save_file)
Expand Down Expand Up @@ -1307,6 +1362,22 @@ class MultipleBrainExtractionOutputSpec(TraitedSpec):


class MultipleBrainExtraction(BaseInterface):
"""
Runs on multiple images the automatic brain extraction module based on a 2D U-Net (Ronneberger et al. [1]_)
using the pre-trained weights from Salehi et al. [2]_.
Calls the BrainExtraction module on a list of images.
See also
------------
pymialsrtk.interfaces.preprocess.BrainExtraction
References
------------
.. [1] Ronneberger et al.; Medical Image Computing and Computer Assisted Interventions, 2015. `(link to paper) <https://arxiv.org/abs/1505.04597>`_
.. [2] Salehi et al.; arXiv, 2017. `(link to paper) <https://arxiv.org/abs/1710.09338>`_
"""

input_spec = MultipleBrainExtractionInputSpec
output_spec = MultipleBrainExtractionOutputSpec

Expand Down

0 comments on commit 113fc84

Please sign in to comment.