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
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
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
def implement(self): dwi = self.getBackupImage('dwi') bEncs = self.getBackupImage('grad', None, 'b') bVals = self.getBackupImage('grad', None, 'bvals') bVecs = self.getBackupImage('grad', None, 'bvecs') (bEncs, bVecs, bVals) = self.__produceEncodingFiles(bEncs, bVecs, bVals, dwi) # Convert bvecs bval expectedLayout = self.get('stride_orientation') if not mriutil.isDataStridesOrientationExpected(dwi, expectedLayout) \ and self.get("force_realign_strides"): self.warning("Reorienting strides for image {}".format(dwi)) self.__stride4DImage(dwi, bEncs, bVecs, bVals, expectedLayout) else: self.info("Linking {} to {}".format( dwi, util.symlink(dwi, self.workingDir))) images = Images( (self.getBackupImage('anat'), 'high resolution'), (self.getBackupImage('b0_pa'), 'B0 posterior to anterior'), (self.getBackupImage('b0_ap'), 'B0 anterior to posterior'), (self.getBackupImage('mag'), 'MR magnitude'), (self.getBackupImage('phase'), 'MR phase '), (self.getBackupImage('aparc_aseg'), 'parcellation'), (self.getBackupImage('anat', 'freesurfer'), 'freesurfer anatomical'), (self.getBackupImage('lh_ribbon'), 'left hemisphere ribbon'), (self.getBackupImage('rh_ribbon'), 'right hemisphere ribbon'), (self.getBackupImage('brodmann'), 'brodmann'), ) for image, description in images.getData(): if image: if not mriutil.isDataStridesOrientationExpected(image, expectedLayout) \ and self.get("force_realign_strides"): self.info( mriutil.stride3DImage(image, self.buildName(image, "stride"), expectedLayout)) else: self.info("Found {} image, linking {} to {}".format( description, image, util.symlink(image, self.workingDir))) for directory in [ os.path.join(self.backupDir, directory) for directory in os.listdir(self.backupDir) if os.path.isdir(os.path.join(self.backupDir, directory)) ]: if mriutil.isAfreesurferStructure(directory): self.info( "{} seem\'s a valid freesurfer structure: linking to {} directory" .format(directory, self.workingDir)) util.symlink(directory, self.workingDir, self.get("parcellation", "id"))
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
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
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: imageQa = self.plot3dVolume(b0, edges=image, fov=image) qaImages.append((imageQa, description)) return qaImages
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
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
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)
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
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
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
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
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
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
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)
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
def meetRequirement(self): images = Images( (self.getDenoisingImage("dwi", 'denoise'), 'denoise'), (self.getPreparationImage("dwi"), 'diffusion weighted')) if not images.isAtLeastOneImageExists(): return False images = Images( (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
def qaSupplier(self): """Create and supply images for the report generated by qa task """ qaImages = Images() #Information on distorsion correction b0_ap = self.getPreparationImage('b0_ap') b0_pa = self.getPreparationImage('b0_pa') mag = self.getPreparationImage('mag') phase = self.getPreparationImage('phase') information = '' if b0_ap and b0_pa: information = 'Distortion correction done with AP and PA images' elif mag and phase: information = 'Distorsion correction done with fieldmap images' else: information = 'No distortion correction done' qaImages.setInformation(information) #Get images dwi = self.getPreparationImage('dwi') dwiCorrected = self.getImage('dwi', 'corrected') brainMask = self.getImage('mask', 'corrected') eddyParameterFiles = self.getImage('dwi', None, 'eddy_parameters') bVecs= self.getPreparationImage('grad', None, 'bvecs') bVecsCorrected = self.getImage('grad', None, 'bvecs') #Build qa names dwiCorrectedGif = self.buildName(dwiCorrected, None, 'gif') dwiCompareGif = self.buildName(dwiCorrected, 'compare', 'gif') translationsPng = self.buildName(dwiCorrected, 'translations', 'png') rotationPng = self.buildName(dwiCorrected, 'rotations', 'png') bVecsGif = self.buildName(dwiCorrected, 'vectors', 'gif') #Build qa images self.slicerGif(dwiCorrected, dwiCorrectedGif, boundaries=brainMask) self.slicerGifCompare(dwi, dwiCorrected, dwiCompareGif, boundaries=brainMask) self.plotMovement(eddyParameterFiles, translationsPng, rotationPng) self.plotvectors(bVecs, bVecsCorrected, bVecsGif) qaImages.extend(Images( (dwiCorrectedGif, 'DWI corrected'), (dwiCompareGif, 'Before and after corrections'), (translationsPng, 'Translation correction by eddy'), (rotationPng, 'Rotation correction by eddy'), (bVecsGif, 'Gradients vectors on the unitary sphere. Red : raw bvec | Blue : opposite bvec | Black + : movement corrected bvec'), )) return qaImages
def meetRequirement(self, result=True): images = Images((self.getBackupImage('anat'), 'high resolution'), (self.getBackupImage('dwi'), 'diffusion weighted')) if images.isSomeImagesMissing(): result = False if not (self.getBackupImage('grad', None, 'b') or (self.getBackupImage('grad', None, 'bvals') and self.getBackupImage('grad', None, 'bvecs'))): self.error("No gradient encoding file found in {}".format(self.backupDir)) result = False return result
def qaSupplier(self): """Create and supply images for the report generated by qa task """ #Get images b0 = self.getUpsamplingImage('b0', 'upsample') brainMask = self.getImage('mask', 'resample') aparcAseg = self.getImage('aparc_aseg', 'resample') wmparc = self.getImage('wmparc', 'resample') tt5 = self.getImage('tt5', 'resample') #Build qa images brainMaskQa = self.plot3dVolume(b0, edges=brainMask, fov=brainMask) aparcAsegQa = self.plot3dVolume(b0, segOverlay=aparcAseg, fov=brainMask) wmparcQa = self.plot3dVolume(b0, segOverlay=wmparc, fov=brainMask) tt5Qas = self.plot4dVolumeToFrames(tt5, fov=brainMask) qaImages = Images( (brainMaskQa, 'Brain mask on upsampled b0'), (aparcAsegQa, 'aparcaseg segmentation on upsampled b0'), (wmparcQa, 'white matter segmentation on upsampled b0'), (tt5Qas[0], 'Cortical grey matter'), (tt5Qas[1], 'Sub-cortical grey matter'), (tt5Qas[2], 'White matter'), (tt5Qas[3], 'CSF'), (tt5Qas[4], 'Pathological tissue'), ) return qaImages
def meetRequirement(self): return Images( (self.getPreparationImage('dwi'), 'diffusion weighted'), (self.getCorrectionImage('mask', 'corrected'), 'brain mask'), (self.getMaskingImage('aparc_aseg', ['253', 'mask']), 'Corpus Callusum mask from the masking task'), (self.getCorrectionImage('b0', 'corrected'), 'B0'))
def isDirty(self): return Images( (self.getImage('brodmann', 'resample'), 'brodmann atlas resample'), (self.getImage('aal2', 'resample'), 'aal2 atlas resample'), (self.getImage('networks7', 'resample'), 'Resting state sevens networks atlas resample'))
def isDirty(self): return Images( (self.getImage('dwi', None, 'txt'), "response function estimation text file"), (self.getImage( 'dwi', 'csd'), "constrained spherical deconvolution"), (self.getImage('dwi', 'nufo'), 'nufo'), (self.getImage('dwi', 'fixel_peak', 'msf'), 'fixel peak image'))
def qaSupplier(self): """Create and supply images for the report generated by qa task """ #Get images b0 = self.getUpsamplingImage('b0', 'upsample') brainMask = self.getRegistrationImage('mask', 'resample') brodmann = self.getImage('brodmann', 'resample') aal2 = self.getImage('aal2', 'resample') networks7 = self.getImage('networks7', 'resample') #Build qa images brodmannQa = self.plot3dVolume(b0, segOverlay=brodmann, fov=brainMask) aal2Qa = self.plot3dVolume(b0, segOverlay=aal2, fov=brainMask) networks7Qa = self.plot3dVolume(b0, segOverlay=networks7, fov=brainMask) qaImages = Images( (brodmannQa, 'Brodmann segmentation on upsampled b0'), (aal2Qa, 'Aal2 segmentation on upsampled b0'), (networks7Qa, 'Resting state sevens networks segmentation ' \ 'on upsampled b0')) return qaImages
def meetRequirement(self): """Validate if all requirements have been met prior to launch the task Returns: True if all requirement are meet, False otherwise """ return Images((self.getParcellationImage('anat', 'freesurfer'), 'anatomical'))
def meetRequirement(self, result=True): images = Images((self.getBackupImage('anat'), 'high resolution'), (self.getBackupImage('dwi'), 'diffusion weighted')) if images.isSomeImagesMissing(): result = False if not (self.getBackupImage('grad', None, 'b') or (self.getBackupImage('grad', None, 'bvals') and self.getBackupImage('grad', None, 'bvecs'))): self.error("No gradient encoding file found in {}".format( self.backupDir)) result = False return result
def isDirty(self): """Validate if this tasks need to be submit for implementation """ return Images( (os.path.join(self.workingDir, 'index.html'), 'QA index.html'), (os.path.join(self.workingDir, self.config.get('qa', 'jquery')), 'Jquery library'))
def qaSupplier(self): """Create and supply images for the report generated by qa task """ anat = self.getImage('anat', 'freesurfer') # Get freesurfer anat norm = self.getImage('norm') brainMask = self.getImage('mask') aparcAseg = self.getImage('aparc_aseg') wmparc = self.getImage('wmparc') tt5 = self.getImage('tt5') # Build qa images anatQa = self.plot3dVolume(anat, fov=brainMask) brainMaskQa = self.plot3dVolume(norm, edges=brainMask, fov=brainMask) aparcAsegQa = self.plot3dVolume(anat, segOverlay=aparcAseg, fov=aparcAseg) wmparcQa = self.plot3dVolume(anat, segOverlay=wmparc, fov=wmparc) tt5Qas = self.plot4dVolumeToFrames(tt5, fov=brainMask) qaImages = Images( (anatQa, 'High resolution anatomical image from Freesurfer'), (brainMaskQa, 'Brain mask on norm from Freesurfer'), (aparcAsegQa, 'Aparc aseg segmentation from Freesurfer'), (wmparcQa, 'White matter segmentation from Freesurfer'), (tt5Qas[0], 'Cortical grey matter'), (tt5Qas[1], 'Sub-cortical grey matter'), (tt5Qas[2], 'White matter'), (tt5Qas[3], 'CSF'), (tt5Qas[4], 'Pathological tissue'), ) return qaImages
def qaSupplier(self): """Create and supply images for the report generated by qa task """ # Get images dwi = self.getDenoisingImage('dwi', 'denoise') if not dwi: dwi = self.getPreparationImage('dwi') dwiCorrected = self.getImage('dwi', 'corrected') brainMask = self.getImage('mask', 'corrected') eddyParameterFiles = self.getImage('dwi', None, 'eddy_parameters') bVecs = self.getPreparationImage('grad', None, 'bvecs') bVecsCorrected = self.getImage('grad', None, 'bvecs') # Build qa images dwiCorrectedQa = self.plot4dVolume(dwiCorrected, fov=brainMask) dwiCompareQa = self.compare4dVolumes(dwi, dwiCorrected, fov=brainMask) translationsQa, rotationsQa = self.plotMovement( eddyParameterFiles, dwiCorrected) bVecsQa = self.plotVectors(bVecs, bVecsCorrected, dwiCorrected) qaImages = Images( (dwiCorrectedQa, 'DWI corrected'), (dwiCompareQa, 'Before and after corrections'), (translationsQa, 'Translation corrections by Eddy'), (rotationsQa, 'Rotation corrections by Eddy'), (bVecsQa, "Gradients vectors on the unitary sphere. " \ "Red: raw bvec | Blue: opposite bvec | " \ "Black +: movement corrected bvec. The more corrected, " \ "the more the + is from the center of the circle.")) # Information on distorsion correction information = "Eddy movement corrections were applied to the images " correctionMethod = self.get('method') if correctionMethod == 'topup': information += "and distortion corrections were conducted on the " \ "AP and PA images." elif correctionMethod == 'fieldmap': information += "using the fieldmap images." else: information += "with no distortion correction" qaImages.setInformation(information) return qaImages
def meetRequirement(self): return Images( (self.getUpsamplingImage('dwi', 'upsample'), "upsampled diffusion"), (self.getUpsamplingImage( 'grad', None, 'bvals'), "gradient value bvals encoding file"), (self.getUpsamplingImage( 'grad', None, 'bvecs'), "gradient vector bvecs encoding file"), (self.getRegistrationImage('mask', 'resample'), 'brain mask'))
def meetRequirement(self): return Images( (self.getUpsamplingImage('dwi', 'upsample'), 'diffusion weighted'), (self.getUpsamplingImage('grad', None, 'b'), "gradient encoding b file"), (self.getMaskingImage('tt5', ['resample', 'wm', 'mask']), 'white matter segmented mask'), (self.getRegistrationImage('mask', 'resample'), 'brain mask'))
def meetRequirement(self): return Images( self.getUpsamplingImage('b0', 'upsample'), self.getRegistrationImage("freesurfer_dwi", ["transformation", "mrtrix"], "mat"), self.getRegistrationImage("freesurfer_dwi", "transformation", "mat"), self.getAtlasImage("brodmann"), self.getAtlasImage("aal2"), self.getAtlasImage("networks7"))
def qaSupplier(self): """Create and supply images for the report generated by qa task """ qaImages = Images() softwareName = "dipy" # Get images dwi = self.getUpsamplingImage("dwi", "upsample") cc = self.getMaskingImage("aparc_aseg", ["253", "mask"]) mask = self.getRegistrationImage("mask", "resample") # Produce hardi odfs image data = {"dwiData": self.__dwiData, "csdModel": self.__csdModel} odfsQa = self.plotReconstruction(data, mask, cc, "hardi_odf", dwi) qaImages.append((odfsQa, "Coronal slice of hardi CSD ODFs in the Corpus Callosum")) # Produce hardi peaks image peaksQa = self.plotReconstruction(self.__csdPeaks, mask, cc, "hardi_peak", dwi) qaImages.append((peaksQa, "Coronal slice of hardi CSD Peaks in the Corpus Callosum")) # Build qa images tags = (("gfa", 1.5, "Generalised Fractional Anisotropy"), ("nufo", 5, "nufo")) 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
def implement(self): dwi = self.getBackupImage('dwi') bEncs = self.getBackupImage('grad', None, 'b') bVals = self.getBackupImage('grad', None, 'bvals') bVecs = self.getBackupImage('grad', None, 'bvecs') (bEncs, bVecs, bVals) = self.__produceEncodingFiles(bEncs, bVecs, bVals, dwi) # Convert bvecs bval expectedLayout = self.get('stride_orientation') if not mriutil.isDataStridesOrientationExpected(dwi, expectedLayout) \ and self.get("force_realign_strides"): self.warning("Reorienting strides for image {}".format(dwi)) self.__stride4DImage(dwi, bEncs, bVecs, bVals, expectedLayout) else: self.info("Linking {} to {}".format(dwi, util.symlink(dwi, self.workingDir))) images = Images( (self.getBackupImage('anat'),'high resolution'), (self.getBackupImage('b0_pa'),'B0 posterior to anterior'), (self.getBackupImage('b0_ap'),'B0 anterior to posterior'), (self.getBackupImage('mag'),'MR magnitude'), (self.getBackupImage('phase'),'MR phase '), (self.getBackupImage('aparc_aseg'),'parcellation'), (self.getBackupImage('anat', 'freesurfer'),'freesurfer anatomical'), (self.getBackupImage('lh_ribbon'),'left hemisphere ribbon'), (self.getBackupImage('rh_ribbon'),'right hemisphere ribbon'), (self.getBackupImage('brodmann'),'brodmann'), ) for image, description in images.getData(): if image: if not mriutil.isDataStridesOrientationExpected(image, expectedLayout) \ and self.get("force_realign_strides"): self.info(mriutil.stride3DImage(image, self.buildName(image, "stride"), expectedLayout)) else: self.info("Found {} image, linking {} to {}".format(description, image, util.symlink(image, self.workingDir))) for directory in [os.path.join(self.backupDir, directory) for directory in os.listdir(self.backupDir) if os.path.isdir(os.path.join(self.backupDir, directory))]: if mriutil.isAfreesurferStructure(directory): self.info("{} seem\'s a valid freesurfer structure: linking to {} directory".format(directory, self.workingDir)) util.symlink(directory, self.workingDir, self.get("parcellation", "id"))
def isDirty(self): return Images( (self.getImage('grad', None, 'bvals'), 'gradient .bvals encoding file'), (self.getImage( 'grad', None, 'bvecs'), 'gradient .bvecs encoding file'), (self.getImage('grad', None, 'b'), 'gradient .b encoding file'), (self.getImage('anat'), 'high resolution'), (self.getImage('dwi'), 'diffusion weighted'))
def isDirty(self): return Images( (self.getImage("dwi", "tensor"), "dipy tensor"), (self.getImage('dwi', 'v1'), "selected eigenvector 1"), (self.getImage('dwi', 'v2'), "selected eigenvector 2"), (self.getImage('dwi', 'v3'), "selected eigenvector 3"), (self.getImage('dwi', 'fa'), "fractional anisotropy"), (self.getImage('dwi', 'md'), "mean diffusivity MD"), (self.getImage('dwi', 'ad'), "selected eigenvalue(s) AD"), (self.getImage('dwi', 'rd'), "selected eigenvalue(s) RD"))
def meetRequirement(self, result=True): """Validate if all requirements have been met prior to launch the task """ return Images( (self.getUpsamplingImage('dwi', 'upsample'), 'diffusion weighted'), (self.getRegistrationImage('mask', 'resample'), 'brain mask'), (self.getUpsamplingImage('grad', None, 'bvals'), '.bvals gradient encoding file'), (self.getUpsamplingImage( 'grad', None, 'bvecs'), '.bvecs gradient encoding file'))
def meetRequirement(self): return Images( (self.getRegistrationImage("aparc_aseg", "resample"), 'resampled parcellation atlas'), (self.getRegistrationImage( "aparc_aseg", "register"), 'register parcellation atlas'), (self.getRegistrationImage('mask', 'resample'), 'brain extracted, resampled high resolution'), (self.getRegistrationImage('mask', 'register'), 'brain extracted, register high resolution'), (self.getRegistrationImage('tt5', 'resample'), '5tt resample'), (self.getRegistrationImage('tt5', 'register'), '5tt register'))
def qaSupplier(self): """Create and supply images for the report generated by qa task """ qaImages = Images() tags = ( ('anat', self.plot3dVolume, 'High resolution anatomical image'), ('dwi', self.plot4dVolume, 'Diffusion weighted image'), ('b0_ap', self.plot3dVolume, 'B0 AP image'), ('b0_pa', self.plot3dVolume, 'B0 PA image'), ('mag', self.plot3dVolume, 'Magnitude image'), ('phase', self.plot3dVolume, 'Phase image'), ) for prefix, plotMethod, description in tags: source = self.getImage(prefix) if source: qaImage = plotMethod(source) qaImages.append((qaImage, description)) return qaImages
def meetRequirement(self): return Images( (self.getParcellationImage('anat', 'freesurfer'), 'high resolution'), (self.getUpsamplingImage('b0', 'upsample'), 'b0 upsampled'), (self.getParcellationImage('aparc_aseg'), 'parcellation'), (self.getParcellationImage('wmparc'), 'parcellation'), (self.getParcellationImage('rh_ribbon'), 'right hemisphere, ribbon'), (self.getParcellationImage('lh_ribbon'), 'left hemisphere ribbon'), (self.getParcellationImage('tt5'), '5tt'), (self.getParcellationImage('mask'), 'brain mask'))
def isDirty(self): return Images((self.getImage('aparc_aseg'), 'parcellation atlas'), (self.getImage('wmparc'), 'wm parcellation'), (self.getImage('anat', 'freesurfer'), 'anatomical'), (self.getImage('rh_ribbon'), 'rh_ribbon'), (self.getImage('lh_ribbon'), 'lh_ribbon'), (self.getImage('norm'), 'norm'), (self.getImage('mask'), 'freesurfer brain masks'), (self.getImage("brainstem"), 'Brainstem label'), (self.getImage("lhHipp"), 'Left Hippocampus label'), (self.getImage("rhHipp"), 'Right Hippocampus label'), (self.getImage('tt5'), '5tt'))
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("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)
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." qaImages.setInformation(information) #get images norm = self.getRegistrationImage("norm", "resample") mask253 = self.getMaskingImage('aparc_aseg',['253','mask']) #images production if self.__nbDirections <= 45 and not self.get('forceHardi'): tags = ( (self.__tckDetRoiTrk, 'fiber crossing aparc_aseg area 253 from a deterministic tensor streamlines'), (self.__tckProbRoiTrk, 'fiber crossing aparc_aseg area 253 from a probabilistic tensor streamlines'), ) else: tags = ( (self.__tckgenRoiTrk, 'fiber crossing aparc_aseg area 253 from a probabilistic hardi streamlines'), (self.__tcksiftRoiTrk, 'fiber crossing aparc_aseg area 253 from a probabilistic hardi streamlines with sift'), ) for data, description in tags: if data is not None: imageQa = self.plotTrk(data, norm, mask253, None, None, 65, -70, 2.5, 185) qaImages.append((imageQa, description)) return qaImages
def isDirty(self): """Validate if this tasks need to be submit for implementation """ return Images( (self.getImage('dwi', 'v1'), "1st eigenvector"), (self.getImage('dwi', 'v2'), "2rd eigenvector"), (self.getImage('dwi', 'v3'), "3rd eigenvector"), (self.getImage('dwi', 'ad'), "selected eigenvalue(s) AD"), (self.getImage('dwi', 'rd'), "selected eigenvalue(s) RD"), (self.getImage('dwi', 'md'), "mean diffusivity"), (self.getImage('dwi', 'fa'), "fractional anisotropy"), (self.getImage('dwi', 'so'), "raw T2 signal with no weighting"))
def qaSupplier(self): """Create and supply images for the report generated by qa task """ qaImages = Images() tags = ( ('anat', 'png', self.slicerPng, 'High resolution anatomical image'), ('dwi', 'gif', self.slicerGif, 'Diffusion weighted image'), ('b0_ap', 'png', self.slicerPng, 'B0 AP image'), ('b0_pa', 'png', self.slicerPng, 'B0 PA image'), ('mag', 'png', self.slicerPng, 'Magnitude image'), ('phase', 'png', self.slicerPng, 'Phase image'), ) for prefix, imageFormat, slicerMethod, description in tags: image = self.getImage(prefix) if image: qaImage = self.buildName(image, None, imageFormat) slicerMethod(image, qaImage) qaImages.extend(Images((qaImage, description))) return qaImages
def isDirty(self): images = Images() if self.__nbDirections <= 45: if 'deterministic' in self.get('algorithm'): images.extend(Images((self.getImage('dwi', 'tensor_det', 'tck'), "deterministic tensor connectome matrix from a streamlines"))) if 'probabilistic' in self.get('algorithm'): images.extend(Images((self.getImage('dwi', 'tensor_prob', 'tck'), "probabilistic tensor connectome matrix from a streamlines"))) else: if 'hardi' in self.get('algorithm'): images.append((self.getImage('dwi', 'hardi_prob', 'tck'), "tckgen hardi probabilistic streamlines tractography")) if 'sift' in self.get('algorithm'): images.extend(Images((self.getImage('dwi', 'tcksift', 'tck'), 'tcksift'))) return images
def __noiseAnalysis(self, dwi, noiseMask, ccMask, qaImages, description): """ """ snrPng = self.buildName(dwi, 'snr', 'png') histPng = self.buildName(dwi, 'hist', 'png') self.noiseAnalysis(dwi, noiseMask, ccMask, snrPng, histPng) qaImages.extend( Images( (snrPng, '{} DWI image: SNR for each volume'.format(description)), (histPng, '{} DWI image: noise histogram'.format(description)), )) return qaImages
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', 'nufo'), ) 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
def qaSupplier(self): """Create and supply images for the report generated by qa task """ qaImages = Images() softwareName = 'dipy' #mask image mask = self.getRegistrationImage('mask', 'resample') #Produce tensor ellipsoids image dwi = self.getUpsamplingImage('dwi', 'upsample') cc = self.getMaskingImage('aparc_aseg', ['253','mask']) ellipsoidsQa = self.plotReconstruction( self.__fit, mask, cc, 'tensor', dwi) qaImages.append(( ellipsoidsQa, 'Coronal slice of tensor ellipsoids in the Corpus Callosum')) #Build qa images tags = ( #(['tensor', 'rgb'], 'RGB map'), ('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
def meetRequirement(self): """Validate if all requirements have been met prior to launch the task Returns: True if all requirement are meet, False otherwise """ images = Images() dwi = self.getUpsamplingImage('dwi', 'upsample') nbDirections = mriutil.getNbDirectionsFromDWI( dwi) # Get number of directions if nbDirections <= 45 and not self.get('tractographymrtrix', 'forceHardi'): postfixTractography = 'tensor_prob' else: postfixTractography = 'hardi_prob' Images((self.getTractographymrtrixImage('dwi', postfixTractography, 'trk'), 'Tractography file'), (self.__getAtlas(), 'Atlas')) # Check if tractographies are available return images
def meetRequirement(self): images = Images( (self.getUpsamplingImage('dwi'), 'diffusion weighted'), (self.getUpsamplingImage('grad', None, 'bvals'), 'gradient .bvals encoding file'), (self.getUpsamplingImage( 'grad', None, 'bvecs'), 'gradient .bvecs encoding file'), (self.getUpsamplingImage('grad', None, 'benc'), 'gradient .b encoding file'), (self.getRegistrationImage('anat', ['freesurfer', 'resample']), 'freesurfer anatomical resample'), (self.getRegistrationImage( 'mask', 'resample'), 'freesurfer mask resample')) #@TODO Add all metrics dependencies return images
def meetRequirement(self): #@TODO add brain mask and 5tt as requierement return Images( (self.getUpsamplingImage('dwi', 'upsample'), 'upsampled diffusion weighted'), (self.getUpsamplingImage( 'grad', None, 'b'), '.b gradient encoding file'), (self.getRegistrationImage("mask", "resample"), 'mask resampled'), (self.getRegistrationImage("norm", "resample"), 'brain resampled'), (self.getMaskingImage( 'aparc_aseg', ['253', 'mask']), 'area 253 from aparc_aseg'), (self.getRegistrationImage("tt5", "register"), '5tt register'), (self.getMaskingImage( 'aparc_aseg', ['1024', 'mask']), 'area 1024 from aparc_aseg'), (self.getMaskingImage("tt5", ["register", "5tt2gmwmi"]), 'grey matter, white matter interface'))
def qaSupplier(self): """Create and supply images for the report generated by qa task """ qaImages = Images() algorithm = self.get("algorithm") #Information on denoising algorithm information = 'Algorithm {} is set'.format(algorithm) if self.matlabWarning: information += ' but matlab is not available on this server' qaImages.setInformation(information) #Get images dwi = self.__getDwiImage() dwiDenoised = self.getImage('dwi', 'denoise') brainMask = self.getCorrectionImage('mask', 'corrected') b0 = self.getCorrectionImage('b0', 'corrected') noiseMask = self.getImage('dwi', 'noise_mask') #Build qa images if dwiDenoised: dwiDenoisedGif = self.buildName(dwiDenoised, None, 'gif') dwiCompareGif = self.buildName(dwiDenoised, 'compare', 'gif') self.slicerGif(dwiDenoised, dwiDenoisedGif, boundaries=brainMask) self.slicerGifCompare(dwi, dwiDenoised, dwiCompareGif, boundaries=brainMask) qaImages.extend(Images( (dwiDenoisedGif, 'Denoised diffusion image'), (dwiCompareGif, 'Before and after denoising'), )) if algorithm == "nlmeans": sigmaPng = self.buildName(dwiDenoised, 'sigma', 'png') noiseMaskPng = self.buildName(noiseMask, None, 'png') self.plotSigma(self.sigmaVector, sigmaPng) self.slicerPng(b0, noiseMaskPng, maskOverlay=noiseMask, boundaries=noiseMask) qaImages.extend(Images( (sigmaPng, 'Sigmas from nlmeans algorithm'), (noiseMaskPng, 'Noise mask from nlmeans algorithm'), )) return qaImages
def qaSupplier(self): """Create and supply images for the report generated by qa task """ qaImages = Images() softwareName = 'dipy' #Get images dwi = self.getUpsamplingImage('dwi', 'upsample') cc = self.getMaskingImage('aparc_aseg', ['253','mask']) mask = self.getRegistrationImage('mask', 'resample') #Produce hardi odfs image data = {'dwiData':self.__dwiData, 'csdModel':self.__csdModel} odfsQa = self.plotReconstruction(data, mask, cc, 'hardi_odf', dwi) qaImages.append(( odfsQa, 'Coronal slice of hardi CSD ODFs in the Corpus Callosum')) #Produce hardi peaks image peaksQa = self.plotReconstruction( self.__csdPeaks, mask, cc, 'hardi_peak', dwi) qaImages.append(( peaksQa, "Coronal slice of hardi CSD Peaks in the Corpus Callosum")) #Build qa images tags = ( ('gfa', 1.5, 'Generalised Fractional Anisotropy'), ('nufo', 5, 'nufo'), ) 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
def qaSupplier(self): """Create and supply images for the report generated by qa task """ qaImages = Images() #Information on denoising algorithm information = 'Denoising was done using the {} algorithm'.format(self.algorithm) if self.algorithm == "nlmeans" and \ self.config.get("denoising", "number_array_coil") == "32": information = "NLMEANS algorithm is not yet implemented for 32 " \ "coils channels images, " if self.config.getboolean("general", "matlab_available"): information += "set algorithm to `lpca` or `aonlm` or " information += "set `ignore: True` into the [denoising] section " \ "of your config.cfg file." if self.matlabWarning: information = "Algorithm `aonlm` or `lpca` was set for the " \ "denoising, but Matlab is not available for this server. "\ "Please install and configure Matlab or set `ignore: True`"\ " into the [denoising] section of your config.cfg file." qaImages.extend(Images((False, 'Denoised diffusion image'))) qaImages.setInformation(information) #Get images dwi = self.getPreparationImage("dwi") dwiDenoised = self.getImage('dwi', 'denoise') brainMask = self.getImage('mask', 'resample') b0 = self.getImage('b0') noiseMask = self.getImage('dwi', 'noise_mask') #Build qa images if dwiDenoised: dwiDenoisedQa = self.plot4dVolume(dwiDenoised, fov=brainMask) qaImages.append((dwiDenoisedQa, 'Denoised diffusion image')) dwiCompareQa = self.compare4dVolumes( dwi, dwiDenoised, fov=brainMask) qaImages.append((dwiCompareQa, 'Before and after denoising')) if self.algorithm == "nlmeans": if self.sigmaVector != None: sigmaQa = self.plotSigma(self.sigmaVector, dwiDenoised) qaImages.append( (sigmaQa, 'Sigmas from the nlmeans algorithm')) if noiseMask: noiseMaskQa = self.plot3dVolume( b0, edges=noiseMask, fov=noiseMask) qaImages.append( (noiseMaskQa, 'Noise mask from the nlmeans algorithm')) return qaImages