本文整理汇总了Python中lib.images.Images类的典型用法代码示例。如果您正苦于以下问题:Python Images类的具体用法?Python Images怎么用?Python Images使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Images类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: qaSupplier
def qaSupplier(self):
"""Create and supply images for the report generated by qa task
"""
qaImages = Images()
softwareName = 'dipy'
#Produce tensor ellipsoids png image
rgb = self.getImage('dwi', ['tensor', 'rgb'])
cc = self.getMaskingImage('aparc_aseg', ['253','mask'])
ellipsoidsPng = self.buildName(rgb, 'ellipsoids', 'png')
self.tensorPng(self.__fit, cc, ellipsoidsPng)
qaImages.extend(Images((ellipsoidsPng, 'Tensor ellipsoids in a part of the CC')))
#Get images
mask = self.getRegistrationImage('mask', 'resample')
#Build qa images
tags = (
#(['tensor', 'rgb'], 'RGB map'),
('fa', 'Fractional anisotropy'),
('ad', 'Axial Diffusivity'),
('md', 'Mean Diffusivity'),
('rd', 'Radial Diffusivity'),
)
for postfix, description in tags:
image = self.getImage('dwi', postfix)
if image:
qaImage = self.buildName(image, softwareName, 'png')
self.slicerPng(image, qaImage, boundaries=mask)
qaImages.extend(Images((qaImage, description)))
return qaImages
示例2: qaSupplier
def qaSupplier(self):
"""Create and supply images for the report generated by qa task
"""
qaImages = Images()
softwareName = 'mrtrix'
#Get images
mask = self.getRegistrationImage('mask', 'resample')
#Build qa images
tags = (
('nufo', 5, 'nufo'),
('afd', 5,'afd')
)
for postfix, vmax, description in tags:
image = self.getImage('dwi', postfix)
if image:
imageQa = self.plot3dVolume(
image, fov=mask, vmax=vmax,
colorbar=True, postfix=softwareName)
qaImages.append((imageQa, description))
return qaImages
示例3: implement
def implement(self):
self.info("Build directories structure for subject: {}".format(os.path.basename(self.workingDir)))
#@TODO add description to that struct
images = Images((self.getSubjectImage('anat'), ""),
(self.getSubjectImage('dwi'), ""),
(self.getSubjectImage('mag',), ""),
(self.getSubjectImage('phase'), ""),
(self.getSubjectImage('aparc_aseg'), ""),
(self.getSubjectImage('anat', 'freesurfer'), ""),
(self.getSubjectImage('lh_ribbon'), ""),
(self.getSubjectImage('rh_ribbon'), ""),
(self.getSubjectImage('brodmann'), ""),
(self.getSubjectImage('b0_ap'), ""),
(self.getSubjectImage('b0_pa'), ""),
(self.getSubjectImage('grad', None, 'b'), ""),
(self.getSubjectImage('grad', None, 'bvals'), ""),
(self.getSubjectImage('grad', None, 'bvecs'), ""),
(self.getSubjectImage('tq_dict', None, 'qry'), ""),
(self.getSubjectImage('queries', None, 'qry'), ""),
(self.getSubjectImage('config', None, 'cfg'), ""),)
for image, description in images.getData():
if image:
self.info("Found {} image: moving it to {} directory".format(description, image, self.workingDir))
shutil.move(image, self.workingDir)
directories = [os.path.join(self.subjectDir, directory) for directory in os.listdir(self.subjectDir) if os.path.isdir(os.path.join(self.subjectDir, directory))]
for directory in directories:
if mriutil.isAfreesurferStructure(directory):
self.info("{} seem\'s a valid freesurfer structure: moving it to {} directory".format(directory, self.workingDir))
shutil.move(directory, self.workingDir)
示例4: qaSupplier
def qaSupplier(self):
"""Create and supply images for the report generated by qa task
"""
qaImages = Images()
softwareName = 'fsl'
#Get images
mask = self.getRegistrationImage('mask', 'resample')
#Build qa images
tags = (
('fa', 0.7, 'Fractional anisotropy'),
('ad', 0.005, 'Axial Diffusivity'),
('md', 0.005, 'Mean Diffusivity'),
('rd', 0.005, 'Radial Diffusivity'),
)
for postfix, vmax, description in tags:
image = self.getImage('dwi', postfix)
if image:
imageQa = self.plot3dVolume(
image, fov=mask, vmax=vmax,
colorbar=True, postfix=softwareName)
qaImages.append((imageQa, description))
#Build SSE image
sse = self.getImage('dwi', 'sse')
sseQa = self.plot3dVolume(
sse, fov=mask, postfix=softwareName, colorbar=True)
qaImages.append((sseQa, 'Sum of squared errors'))
return qaImages
示例5: qaSupplier
def qaSupplier(self):
"""Create and supply images for the report generated by qa task
"""
qaImages = Images()
#Get images
dwiNative = self.getPreparationImage('dwi')
dwiCorrected = self.getCorrectionImage('dwi', 'corrected')
dwiDenoised = self.getDenoisingImage('dwi', 'denoise')
noiseMask = self.getImage('mask', ['corrected', 'noisemask'])
ccMask = self.getImage('aparc_aseg', ['253', 'mask', 'downsample'])
b0 = self.getCorrectionImage('b0', 'corrected')
#Build qa images
tags = (
(dwiNative, 'Native'),
(dwiDenoised, 'denoised'),
(dwiCorrected, 'Corrected'),
)
for dwi, description in tags:
if dwi:
qaImages = self.__noiseAnalysis(dwi, noiseMask, ccMask, qaImages, description)
#Build qa masks images
tags = (
(noiseMask, 'Noise mask'),
(ccMask, 'Corpus callosum mask'),
)
for mask, description in tags:
maskPng = self.buildName(mask, None, 'png')
self.slicerPng(b0, maskPng, maskOverlay=mask, boundaries=mask)
qaImages.append((maskPng, description))
return qaImages
示例6: qaSupplier
def qaSupplier(self):
"""Create and supply images for the report generated by qa task
"""
qaImages = Images()
softwareName = 'mrtrix'
#Set information
information = "Estimation using WLS with {} iteration(s)".format(self.get('iter'))
qaImages.setInformation(information)
#Get images
mask = self.getRegistrationImage('mask', 'resample')
#Build qa images
tags = (
('fa', 0.7, 'Fractional anisotropy'),
('ad', 0.005, 'Axial Diffusivity'),
('md', 0.005, 'Mean Diffusivity'),
('rd', 0.005, 'Radial Diffusivity'),
)
for postfix, vmax, description in tags:
image = self.getImage('dwi', postfix)
if image:
imageQa = self.plot3dVolume(
image, fov=mask, vmax=vmax,
colorbar=True, postfix=softwareName)
qaImages.append((imageQa, description))
return qaImages
示例7: qaSupplier
def qaSupplier(self):
"""Create and supply images for the report generated by qa task
"""
qaImages = Images()
softwareName = 'dipy'
#Get images
mask = self.getRegistrationImage('mask', 'resample')
#Build qa images
tags = (
('fa', 'Fractional anisotropy'),
('ad', 'Axial Diffusivity'),
('md', 'Mean Diffusivity'),
('rd', 'Radial Diffusivity'),
)
for postfix, description in tags:
image = self.getImage('dwi', postfix)
if image:
qaImage = self.buildName(image, softwareName, 'png')
self.slicerPng(image, qaImage, boundaries=mask)
qaImages.extend(Images((qaImage, description)))
return qaImages
示例8: qaSupplier
def qaSupplier(self):
"""Create and supply images for the report generated by qa task
"""
qaImages = Images()
#Get images
b0 = self.getUpsamplingImage('b0', 'upsample')
whiteMatter = self.getImage("tt5", ["resample", "wm", "mask"])
interfaceGmWm = self.getImage("tt5", ["register", "5tt2gmwmi"])
area253 = self.getImage('aparc_aseg',['253','mask'])
area1024 = self.getImage('aparc_aseg',['1024','mask'])
#Build qa images
tags = (
(whiteMatter, 'resample white segmented mask'),
#(interfaceGmWm, 'grey matter, white matter interface'),
#(area253, 'area 253 from aparc_aseg atlas'),
#(area1024, 'area 1024 from aparc_aseg atlas'),
)
for image, description in tags:
qaImage = self.buildName(image, None, 'png')
self.slicerPng(b0, qaImage, maskOverlay=image, boundaries=image)
qaImages.extend(Images((qaImage, description)))
return qaImages
示例9: qaSupplier
def qaSupplier(self):
"""Create and supply images for the report generated by qa task
"""
qaImages = Images()
# Get images
dwiNative = self.getPreparationImage("dwi")
dwiCorrected = self.getCorrectionImage("dwi", "corrected")
dwiDenoised = self.getDenoisingImage("dwi", "denoise")
noiseMask = self.getImage("mask", ["corrected", "noisemask"])
ccMask = self.getImage("aparc_aseg", ["253", "mask", "downsample"])
b0 = self.getCorrectionImage("b0", "corrected")
# Build qa images
tags = ((dwiNative, "Native"), (dwiDenoised, "denoised"), (dwiCorrected, "Corrected"))
for dwi, description in tags:
if dwi:
qaImages = self.__noiseAnalysis(dwi, noiseMask, ccMask, qaImages, description)
# Build qa masks images
tags = ((noiseMask, "Noise mask"), (ccMask, "Corpus callosum mask"))
for mask, description in tags:
maskPng = self.buildName(mask, None, "png")
self.slicerPng(b0, maskPng, maskOverlay=mask, boundaries=mask)
qaImages.append((maskPng, description))
return qaImages
示例10: qaSupplier
def qaSupplier(self):
"""Create and supply images for the report generated by qa task
"""
qaImages = Images()
information = "Warning: due to storage restriction, streamlines were " \
"downsampled. Even if there is no difference in structural " \
"connectivity, you should be careful before computing any " \
"metrics along these streamlines.\n To run toad without this " \
"downsampling, please refer to the documentation."
if self.defaultQuery:
# get images
norm = self.getRegistrationImage("norm", "resample")
self.__buildNameTractQuerierOutputs()
# images production
tags = (
(self.queries[0],
'Corpus Callosum',
95, 60, 40, -80, 0, 160),
(self.queries[1],
'Inferior Fronto Occipital tract left',
95, 80, 40, -90, 0, 90),
(self.queries[2],
'Inferior Fronto Occipital tract right',
95, 80, 40, -90, 0, -90),
(self.queries[3],
'inferior Longitudinal Fasciculus left',
95, 80, 40, -90, 0, 90),
(self.queries[4],
'Inferior Longitudinal Fasciculus right',
95, 80, 40, -90, 0, -90),
(self.queries[5],
'Uncinate Fasciculus left',
95, 80, 40, -90, 0, 90),
(self.queries[6],
'Uncinate Fasciculus right',
95, 80, 40, -90, 0, -90),
(self.queries[7],
'Corticospinal tract Left',
95, 80, 40, -90, 0, 160),
(self.queries[8],
'Corticospinal tract right',
95, 80, 40, -90, 0, 200),
)
for data, description, xSlice, ySlice, zSlice, xRot, yRot, zRot in tags:
if data:
imageQa = self.plotTrk(data, norm, None, xSlice, ySlice, zSlice, xRot, yRot, zRot)
qaImages.append((imageQa, description))
else:
information = """
Because you didn't choose default queries and dictionnary,
we are not able to create proper screenshots of the output bundles.
"""
qaImages.setInformation(information)
return qaImages
示例11: isDirty
def isDirty(self):
images = Images()
dwi = self.getUpsamplingImage('dwi', 'upsample')
if mriutil.getNbDirectionsFromDWI(dwi) <= 45 and not self.get('forceHardi'):
if 'deterministic' in self.get('algorithm'):
images.append((
self.getImage('dwi', 'tensor_det', 'trk'),
"deterministic tensor connectome matrix from a streamlines"
))
if 'probabilistic' in self.get('algorithm'):
images.append((
self.getImage('dwi', 'tensor_prob', 'trk'),
"probabilistic tensor connectome matrix from a streamlines"
))
else:
images.append((
self.getImage('dwi', 'hardi_prob', 'trk'),
"tckgen hardi probabilistic streamlines tractography"
))
if self.get('sift'):
images.append((
self.getImage('dwi', 'tcksift', 'trk'), 'tcksift'))
return images
示例12: meetRequirement
def meetRequirement(self, result=True):
#@TODO add gradient files validation and correct this function
images = Images((self.getDenoisingImage("dwi", 'denoise'), 'denoised'),
(self.getCorrectionImage("dwi", 'corrected'), 'corrected'),
(self.getPreparationImage("dwi"), 'diffusion weighted'))
if images.isNoImagesExists():
self.warning("No proper dwi image found as requirement")
result = False
return result
示例13: meetRequirement
def meetRequirement(self, result = True):
images = Images((self.getCorrectionImage("dwi", 'corrected'), 'corrected'),
(self.getPreparationImage("dwi"), 'diffusion weighted'))
if not images.isAtLeastOneImageExists():
return False
images = Images((self.getParcellationImage('norm'), 'freesurfer normalize'),
(self.getParcellationImage('mask'), 'freesurfer mask'))
return images
示例14: implement
def implement(self):
self.info("Build directories structure for subject: {}".format(
os.path.basename(self.workingDir)))
#@TODO add description to that struct
images = Images((self.getSubjectImage('anat'), ""),
(self.getSubjectImage('dwi'), ""),
(self.getSubjectImage('mag',), ""),
(self.getSubjectImage('phase'), ""),
(self.getSubjectImage('aparc_aseg'), ""),
(self.getSubjectImage('anat', 'freesurfer'), ""),
(self.getSubjectImage('lh_ribbon'), ""),
(self.getSubjectImage('rh_ribbon'), ""),
(self.getSubjectImage('brodmann'), ""),
(self.getSubjectImage('b0_ap'), ""),
(self.getSubjectImage('b0_pa'), ""),
(self.getSubjectImage('grad', None, 'b'), ""),
(self.getSubjectImage('grad', None, 'bvals'), ""),
(self.getSubjectImage('grad', None, 'bvecs'), ""),
(self.getSubjectImage('tq_dict', None, 'qry'), ""),
(self.getSubjectImage('queries', None, 'qry'), ""),
(self.getSubjectImage('config', None, 'cfg'), ""),)
for image, description in images.getData():
if image:
self.info("Found {} image: moving it to {} directory".format(
description, image, self.workingDir))
shutil.move(image, self.workingDir)
directories = []
for directory in os.listdir(self.subjectDir):
target = os.path.join(self.subjectDir, directory)
if os.path.isdir(target):
directories.append(target)
for directory in directories:
if mriutil.isAfreesurferStructure(directory):
self.info("{} seem\'s a valid freesurfer structure: moving it to {} directory".format(directory, self.workingDir))
if os.path.islink(directory):
os.chdir(self.subjectDir)
# We need to chdir because `directory` is in
# `self.subjectDir` and we need `os.path.abspath` to
# work correctly
fsDirName = os.path.basename(directory)
linkto = os.path.abspath(os.readlink(directory))
newLinkto = os.path.relpath(linkto, self.workingDir)
newTarget = os.path.join(self.workingDir, fsDirName)
os.symlink(newLinkto, newTarget)
os.unlink(directory)
os.chdir(self.workingDir)
else:
shutil.move(directory, self.workingDir)
示例15: meetRequirement
def meetRequirement(self):
images = Images((self.getPreparationImage('dwi'), 'diffusion weighted'),
(self.getParcellationImage('norm'), 'freesurfer normalize'),
(self.getParcellationImage('mask'), 'freesurfer mask'),
(self.getPreparationImage('grad', None, 'bvals'), 'gradient .bvals encoding file'),
(self.getPreparationImage('grad', None, 'bvecs'), 'gradient .bvecs encoding file'),
(self.getPreparationImage('grad', None, 'b'), 'gradient .b encoding file'))
#if fieldmap available
if Images(self.getPreparationImage("mag") , self.getPreparationImage("phase")).isAllImagesExists():
images.append((self.getParcellationImage('anat', 'freesurfer'),"freesurfer anatomical"))
return images