def implement(self): tt5 = self.getRegistrationImage("tt5", "register") seed_gmwmi = self.getMaskingImage("tt5", ["register", "5tt2gmwmi"]) brodmann = self.getRegistrationImage("brodmann", "resample") norm = self.getRegistrationImage("norm", "resample") mask253 = self.getMaskingImage('aparc_aseg', ['253', 'mask']) mask1024= self.getMaskingImage('aparc_aseg', ['1024', 'mask']) dwi = self.getUpsamplingImage('dwi', 'upsample') bFile = self.getUpsamplingImage('grad', None, 'b') mask = self.getRegistrationImage('mask', 'resample') #tensor part tckDet = self.__tckgenTensor(dwi, self.buildName(dwi, 'tensor_det', 'tck'), mask, tt5, seed_gmwmi, bFile, 'Tensor_Det') tckDetConnectome = self.__tck2connectome(tckDet, brodmann, self.buildName(tckDet, 'connectome', 'csv')) tckDetConnectomeNormalize = self.__normalizeConnectome(tckDetConnectome, self.buildName(tckDetConnectome, 'normalize', 'csv')) mriutil.plotConnectome(tckDetConnectomeNormalize, self.buildName(tckDetConnectomeNormalize, None, "png")) tckDetRoi = self.__tckedit(tckDet, mask253, self.buildName(tckDet, 'roi','tck')) tckDetRoiTrk = mriutil.tck2trk(tckDetRoi, norm , self.buildName(tckDetRoi, None, 'trk')) tckProb = self.__tckgenTensor(dwi, self.buildName(dwi, 'tensor_prob', 'tck'), mask, tt5, seed_gmwmi, bFile, 'Tensor_Prob') tckProbConnectome = self.__tck2connectome(tckProb, brodmann, self.buildName(tckProb, 'connectome', 'csv')) tckProbConnectomeNormalize = self.__normalizeConnectome(tckProbConnectome, self.buildName(tckProbConnectome, 'normalize', 'csv')) mriutil.plotConnectome(tckProbConnectomeNormalize, self.buildName(tckProbConnectomeNormalize, None, "png")) tckProbRoi = self.__tckedit(tckProb, mask253, self.buildName(tckProb, 'roi','tck')) tckProbRoiTrk = mriutil.tck2trk(tckProbRoi, norm , self.buildName(tckProbRoi, None, 'trk')) #HARDI part csd = self.getHardimrtrixImage('dwi','csd') hardiTck = self.__tckgenHardi(csd, self.buildName(csd, 'hardi_prob', 'tck'), tt5) hardiTckConnectome = self.__tck2connectome(hardiTck, brodmann, self.buildName(hardiTck, 'connectome', 'csv')) hardiTckConnectomeNormalize = self.__normalizeConnectome(hardiTckConnectome, self.buildName(hardiTckConnectome, 'normalize', 'csv')) mriutil.plotConnectome(hardiTckConnectomeNormalize, self.buildName(hardiTckConnectomeNormalize, None, "png")) hardiTckRoi = self.__tckedit(hardiTck, mask253, self.buildName(hardiTck, 'roi','tck')) tckgenRoiTrk = mriutil.tck2trk(hardiTckRoi, norm , self.buildName(hardiTckRoi, None, 'trk')) tcksift = self.__tcksift(hardiTck, csd) tcksiftConnectome = self.__tck2connectome(tcksift, brodmann, self.buildName(tcksift, 'connectome', 'csv')) tcksiftConnectomeNormalize = self.__normalizeConnectome(tcksiftConnectome, self.buildName(tcksiftConnectome, 'normalize', 'csv')) mriutil.plotConnectome(tcksiftConnectomeNormalize, self.buildName(tcksiftConnectomeNormalize, None, "png")) tcksiftRoi = self.__tckedit(tcksift, mask253, self.buildName(tcksift, 'roi', 'tck')) tcksiftRoiTrk = mriutil.tck2trk(tcksiftRoi, norm , self.buildName(tcksiftRoi, None, 'trk')) #create PNG if self.get('general', 'vtk_available'): mriutil.createVtkPng(tckDetRoiTrk, norm, mask253) mriutil.createVtkPng(tckProbRoiTrk, norm, mask253) mriutil.createVtkPng(tckgenRoiTrk, norm, mask253) mriutil.createVtkPng(tcksiftRoiTrk, norm, mask253)
def __plotConnectome(self, source, atlas, lut, prefix): """ perform connectomme steps. Args: source: the input track file atlas: the atlas lut: an compatible itksnap lut file Returns: a connectome png image """ if lut is not None: lutFile= os.path.join(self.toadDir, "templates", "lookup_tables", self.get("template", lut)) else: lutFile= None if self.get('arguments', 'debug'): self.info('Source file: {}'.format(source)) self.info('Atlas file: {}'.format(atlas)) self.info('Lut file location: {}'.format(lutFile)) connectome = self.__tck2connectome(source, atlas, self.buildName(source, [ prefix , 'connectome'], 'csv')) connectomeNormalize = self.__normalizeConnectome(connectome, self.buildName(connectome, 'normalize', 'csv')) pngImage = mriutil.plotConnectome(connectomeNormalize, self.buildName(connectomeNormalize, None, "png"), lutFile) return pngImage
def __plotConnectome(self, source, atlas, lut, prefix): """ perform connectomme steps. Args: source: the input track file atlas: the atlas lut: an compatible itksnap lut file Returns: a connectome png image """ if lut is not None: lutFile = os.path.join(self.toadDir, "templates", "lookup_tables", self.get("template", lut)) else: lutFile = None if self.get('arguments', 'debug'): self.info('Source file: {}'.format(source)) self.info('Atlas file: {}'.format(atlas)) self.info('Lut file location: {}'.format(lutFile)) connectome = self.__tck2connectome( source, atlas, self.buildName(source, [prefix, 'connectome'], 'csv')) connectomeNormalize = self.__normalizeConnectome( connectome, self.buildName(connectome, 'normalize', 'csv')) pngImage = mriutil.plotConnectome( connectomeNormalize, self.buildName(connectomeNormalize, None, "png"), lutFile) return pngImage