Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@staticmethod
def get_atlas_map():
import os
FSLDIR = os.environ.get('FSLDIR', '')
if not FSLDIR:
raise Exception('FSLDIR variable from FSL software is not set')
return os.path.join(FSLDIR, 'data', 'atlases', 'JHU', 'JHU-ICBM-FA-1mm.nii.gz')
@staticmethod
def get_tsv_roi():
from os.path import join, split, realpath
return join(split(realpath(__file__))[0], '../resources/atlases', 'JHUTract_FS_LUT_newformat.txt')
class JHUTracts252mm(AtlasAbstract):
def __init__(self):
AtlasAbstract.__init__(self)
@staticmethod
def get_name_atlas(): return "JHUTracts25"
@staticmethod
def get_atlas_labels():
import os
FSLDIR = os.environ.get('FSLDIR', '')
if not FSLDIR:
raise Exception('FSLDIR variable from FSL software is not set')
return os.path.join(FSLDIR, 'data', 'atlases', 'JHU', 'JHU-ICBM-tracts-maxprob-thr25-2mm.nii.gz')
@staticmethod
def get_atlas_map():
if not os.path.exists(os.path.join(SPM_HOME, 'toolbox', 'cat12')):
raise Exception('CAT12 not included in SPM_HOME/toolbox')
return os.path.join(SPM_HOME, 'toolbox', 'cat12', 'templates_1.50mm', 'hammers.nii')
@staticmethod
def get_atlas_map():
from os.path import join, split, realpath
return join(split(realpath(__file__))[0], '../resources/atlases_spm', 'Template_MNI152.nii')
@staticmethod
def get_tsv_roi():
from os.path import join, split, realpath
return join(split(realpath(__file__))[0], '../resources/atlases_spm', 'lut_Hammers_newformat.txt')
class LPBA40(AtlasAbstract):
def __init__(self):
AtlasAbstract.__init__(self)
@staticmethod
def get_name_atlas(): return "LPBA40"
@staticmethod
def get_atlas_labels():
import os
import platform
if "SPM_HOME" not in os.environ:
raise Exception('SPM_HOME variable from SPM software is not set')
else:
if "SPMSTANDALONE_HOME" in os.environ:
if platform.system() == 'Darwin':
SPM_HOME = os.environ['SPMSTANDALONE_HOME'] + "/spm12.app/Contents/MacOS/spm12_mcr"
def get_atlas_labels():
from os.path import join, split, realpath
return join(split(realpath(__file__))[0], '../resources/atlases_spm', 'AAL2.nii')
@staticmethod
def get_atlas_map():
from os.path import join, split, realpath
return join(split(realpath(__file__))[0], '../resources/atlases_spm', 'Template_MNI152.nii')
@staticmethod
def get_tsv_roi():
from os.path import join, split, realpath
return join(split(realpath(__file__))[0], '../resources/atlases_spm', 'lut_AAL2_newformat.txt')
class Hammers(AtlasAbstract):
def __init__(self):
AtlasAbstract.__init__(self)
@staticmethod
def get_name_atlas(): return "Hammers"
@staticmethod
def get_atlas_labels():
import os
import platform
if "SPM_HOME" not in os.environ:
raise Exception('SPM_HOME variable from SPM software is not set')
else:
if "SPMSTANDALONE_HOME" in os.environ:
if platform.system() == 'Darwin':
SPM_HOME = os.environ['SPMSTANDALONE_HOME'] + "/spm12.app/Contents/MacOS/spm12_mcr"
@staticmethod
def get_atlas_map():
import os
FSLDIR = os.environ.get('FSLDIR', '')
if not FSLDIR:
raise Exception('FSLDIR variable from FSL software is not set')
return os.path.join(FSLDIR, 'data', 'atlases', 'JHU', 'JHU-ICBM-FA-2mm.nii.gz')
@staticmethod
def get_tsv_roi():
from os.path import join, split, realpath
return join(split(realpath(__file__))[0], '../resources/atlases', 'JHUTract_FS_LUT_newformat.txt')
class JHUTracts501mm(AtlasAbstract):
def __init__(self):
AtlasAbstract.__init__(self)
@staticmethod
def get_name_atlas(): return "JHUTracts50"
@staticmethod
def get_atlas_labels():
import os
FSLDIR = os.environ.get('FSLDIR', '')
if not FSLDIR:
raise Exception('FSLDIR variable from FSL software is not set')
return os.path.join(FSLDIR, 'data', 'atlases', 'JHU', 'JHU-ICBM-tracts-maxprob-thr50-1mm.nii.gz')
@staticmethod
def get_atlas_map():
@staticmethod
def get_atlas_map():
import os
FSLDIR = os.environ.get('FSLDIR', '')
if not FSLDIR:
raise Exception('FSLDIR variable from FSL software is not set')
return os.path.join(FSLDIR, 'data', 'atlases', 'JHU', 'JHU-ICBM-FA-2mm.nii.gz')
@staticmethod
def get_tsv_roi():
from os.path import join, split, realpath
return join(split(realpath(__file__))[0], '../resources/atlases', 'JHUTract_FS_LUT_newformat.txt')
class AAL2(AtlasAbstract):
def __init__(self):
AtlasAbstract.__init__(self)
@staticmethod
def get_name_atlas(): return "AAL2"
@staticmethod
def get_atlas_labels():
from os.path import join, split, realpath
return join(split(realpath(__file__))[0], '../resources/atlases_spm', 'AAL2.nii')
@staticmethod
def get_atlas_map():
from os.path import join, split, realpath
return join(split(realpath(__file__))[0], '../resources/atlases_spm', 'Template_MNI152.nii')
in_atlas (:obj: AbstractClass): An atlas with a set of ROI. These ROI
are used to compute statistics.
out_file (Optional[str]): Name of the output file.
Returns:
out_file (str): TSV file containing the statistics (content of the
columns: label, mean scalar, std of the scalar', number of voxels).
"""
from clinica.utils.atlas import AtlasAbstract
import nibabel as nib
import numpy as np
import pandas
import os.path as op
from clinica.utils.stream import cprint
if not isinstance(in_atlas, AtlasAbstract):
raise Exception("Atlas element must be an AtlasAbstract type")
if out_file is None:
fname, ext = op.splitext(op.basename(in_normalized_map))
if ext == ".gz":
fname, ext2 = op.splitext(fname)
ext = ext2 + ext
out_file = op.abspath("%s_statistics_%s.tsv"
% (fname, in_atlas.get_name_atlas()))
atlas_labels = nib.load(in_atlas.get_atlas_labels())
atlas_labels_data = atlas_labels.get_data()
img = nib.load(in_normalized_map)
img_data = img.get_data()
"""
pass
def get_index(self):
import nibabel as nib
import numpy as np
img_labels = nib.load(self.get_atlas_labels())
img_labels = img_labels.get_data()
labels = list(set(img_labels.ravel()))
index_vector = np.zeros(len(labels))
for index, n in enumerate(labels):
index_vector[index] = index
return index_vector
class JHUDTI812mm(AtlasAbstract):
def __init__(self):
AtlasAbstract.__init__(self)
@staticmethod
def get_name_atlas(): return "JHUDTI81"
@staticmethod
def get_atlas_labels():
import os
FSLDIR = os.environ.get('FSLDIR', '')
if not FSLDIR:
raise Exception('FSLDIR variable from FSL software is not set')
return os.path.join(FSLDIR, 'data', 'atlases', 'JHU', 'JHU-ICBM-labels-2mm.nii.gz')
@staticmethod
def get_atlas_map():
out_md_statistics (str): Statistics of the MD-map on .
out_ad_statistics (str): Statistics of the AD-map on .
out_rd_statistics (str): Statistics of the RD-map on .
"""
import tempfile
import os
import nipype.interfaces.io as nio
import nipype.interfaces.utility as niu
import nipype.pipeline.engine as pe
from clinica.utils.atlas import AtlasAbstract
from clinica.utils.mri_registration import ants_registration_syn_quick
from clinica.utils.mri_registration import apply_ants_registration_syn_quick_transformation
from clinica.utils.statistics import statistics_on_atlas
if not isinstance(atlas, AtlasAbstract):
raise Exception("Atlas element must be an AtlasAbstract type")
if working_directory is None:
working_directory = tempfile.mkdtemp()
inputnode = pe.Node(niu.IdentityInterface(
fields=['in_fa', 'in_md', 'in_ad', 'in_rd', 'in_atlas_scalar_image', 'in_atlas_labels']),
name='inputnode')
inputnode.inputs.in_atlas_scalar_image=atlas.get_atlas_map()
inputnode.inputs.in_atlas_labels=atlas.get_atlas_labels()
ants_registration = pe.Node(interface=niu.Function(
input_names=['fixe_image', 'moving_image', 'prefix_output'],
output_names=['image_warped', 'affine_matrix', 'warp', 'inverse_warped', 'inverse_warp'],
function=ants_registration_syn_quick), name='ants_registration')
def __init__(self):
AtlasAbstract.__init__(self)
def add_atlas(self, atlas):
if not isinstance(atlas, AtlasAbstract):
raise Exception("Atlas element must be an AtlasAbstract type")