def five_tissue(t1_registered: str, t1_mask_registered): out_file = f"{os.path.dirname(t1_registered)}/5TT.mif" out_vis = f"{os.path.dirname(t1_registered)}/vis.mif" seg = mrt.Generate5tt() seg.inputs.in_file = t1_registered seg.inputs.out_file = out_file seg.inputs.algorithm = "fsl" cmd = seg.cmdline + f" -mask {t1_mask_registered}" print(cmd) os.system(cmd) os.system(f"5tt2vis {out_file} {out_vis}") return out_vis, out_file
def create_tissue_classification_node(): """ Instanciate T1 volume tissue classification Nipype node :return: tissue_classif (Nipype Node) """ # Tissue classification from T1 MRI data tissue_classif = pe.Node(interface=mrtrix3.Generate5tt(), name="tissue_classif") # rely on FSL for T1 tissue segmentation tissue_classif.inputs.algorithm = "fsl" tissue_classif.inputs.out_file = "5tt.nii.gz" return tissue_classif
def gen_5tt_pipeline(self, **name_maps): pipeline = self.new_pipeline( name='gen5tt', name_maps=name_maps, desc=("Generate 5-tissue-type image used for Anatomically-" "Constrained Tractography (ACT)")) aseg_path = pipeline.add( 'aseg_path', AppendPath(sub_paths=['mri', 'aseg.mgz']), inputs={'base_path': ('fs_recon_all', directory_format)}) pipeline.add( 'gen5tt', mrtrix3.Generate5tt(algorithm='freesurfer', out_file='5tt.mif'), inputs={'in_file': (aseg_path, 'out_path')}, outputs={'five_tissue_type': ('out_file', mrtrix_image_format)}, requirements=[mrtrix_req.v('3.0rc3'), freesurfer_req.v('6.0')]) return pipeline
def five_tissue(t1_registered: Path, t1_mask_registered: Path): """ Generate 5TT (5-tissue-type) image based on the registered T1 image. Arguments: t1_registered {Path} -- [T1 registered to DWI space] t1_mask_registered {Path} -- [T1 mask] Returns: [type] -- [5TT and vis files] """ out_file = Path(t1_registered.parent / "5TT.mif") out_vis = Path(t1_registered.parent / "vis.mif") if not out_file.is_file(): seg = mrt.Generate5tt() seg.inputs.in_file = t1_registered seg.inputs.out_file = out_file seg.inputs.algorithm = "fsl" cmd = seg.cmdline + f" -mask {t1_mask_registered}" print(cmd) seg.run() if not out_vis.is_file(): os.system(f"5tt2vis {str(out_file)} {str(out_vis)}") return out_vis, out_file
# Bias correction of the diffusion MRI data (for more quantitative approach) dwibiascorrect = pe.Node(interface=mrtrix3.preprocess.DWIBiasCorrect(), name="dwibiascorrect") dwibiascorrect.use_ants = True # gross brain mask stemming from DWI data dwi2mask = pe.Node(interface=mrtrix3.utils.BrainMask(), name="dwi2mask") # tensor coefficients estimation dwi2tensor = pe.Node(interface=mrtrix3.reconst.FitTensor(), name="dwi2tensor") # derived FA contrast for registration tensor2fa = pe.Node(interface=mrtrix3.TensorMetrics(), name="tensor2fa") # Tissue classification from T1 MRI data tissue_classif = pe.Node(interface=mrtrix3.Generate5tt(), name="tissue_classif") # rely on FSL for T1 tissue segmentation tissue_classif.inputs.algorithm = "fsl" # impulsionnal response estimation dwi2response = pe.Node(interface=mrtrix3.preprocess.ResponseSD(), name="dwi2response") dwi2response.inputs.algorithm = "msmt_5tt" # Multi-shell multi tissue spherical deconvolution of the diffusion MRI data dwi2fod = pe.Node( interface=mrtrix3.reconst.ConstrainedSphericalDeconvolution(), name="msmt-csd") # Probabilistic and anatomically constrained whole brain local tractography
from os.path import join as opj import os import json from nipype.interfaces import fsl from nipype.interfaces.spm import Smooth from nipype.interfaces.utility import IdentityInterface from nipype.interfaces.io import SelectFiles, DataSink from nipype.algorithms.rapidart import ArtifactDetect from nipype import Workflow, Node import copy from nipype.interfaces.ants import N4BiasFieldCorrection import nipype.interfaces.mrtrix3 as mrt gen5tt = mrt.Generate5tt() n4 = N4BiasFieldCorrection() # Variables USE parse argument bids_dir = '~/tmp/BIDS' #experiment_dir output_dir = '~/tmp/derivatives' working_dir = '/tmp/' participant_label='sub-HC10' # ---------------------------------------------------------------- # T1w processing # check https://github.com/llevitis/APPIAN # Initiate a node to Reorient to RPI with AFNI reorient = Node(afni.)