def eddyCorrection(self,filename, ref=0):
     from PythonDiffusion import eddyCorrection
     starttime=datetime.now()
     print "Applying eddy current correction."
     eddyCorrection(self, filename, ref)
     time=datetime.now()-starttime
     print "Eddy current correction completed in %r seconds." %time.seconds
Exemple #2
0
 def eddyCorrection(self, filename=0, ref=0, protocol='eddy_v'):
     from PythonDiffusion import eddyCorrection
     starttime = datetime.now()
     print "Applying eddy current correction."
     if filename == 0:
         filename = self.name + '_EC'
     eddyCorrection(self, filename=filename, ref=ref, protocol=protocol)
     time = datetime.now() - starttime
     print "Eddy current correction completed in %r seconds." % time.seconds
 def processDiffusion(self,ec=False, bv=None):
     print "Processing diffusion, full pipeline."
     from PythonDiffusion import rescaleImage, eddyCorrection
     from datetime import datetime
     if self.nrep==1:
         print "Applying slope correction..."
         rescaleImage(self)
     if ec:
         print "ec=True. Applying eddy current correction."
         eddyCorrection(self,self.name+'_EC', protocol='eddy_v')
     self.tensorFit(bv=bv)
Exemple #4
0
 def processDiffusion(self,
                      ec=False,
                      bv=None,
                      mode='dti',
                      removea0=0,
                      mask=True):
     print "Processing diffusion, full pipeline."
     from PythonDiffusion import rescaleImage, eddyCorrection
     from datetime import datetime
     if self.nrep == 1:
         print "Applying slope correction..."
         rescaleImage(self)
     if ec:
         print "ec=True. Applying eddy current correction."
         eddyCorrection(self, self.name + '_EC', protocol='eddy_correct')
     if mode == 'dti' or mode == 'RESTORE':
         self.tensorFit(bv=bv, removea0=removea0, m=mode, mask=mask)
     elif mode == 'dki':
         self.processKurtosis()
Exemple #5
0
                os.path.join(filen, filen + "_nonselT1fit"))
            aslimg.save_output(os.path.join(filen, filen + '_Full'))
            pl.close()
        except ValueError:
            print "Image shape incorrect: ", aslimg.shape, "Not compatible with amount of inversion times provided."

    elif ("dti" in im.protocol.lower() or "dwi" in im.protocol.lower()
          or "dki" in im.protocol.lower()
          or 'trace' in im.protocol.lower()) and im.name[-1] == '1':
        dtimg = DiffusionImg(filen)
        if not ((len(dtimg.bvals) - dtimg.nA0) / len(dtimg.dwdir) >= 1
                and len(dtimg.dwdir) > 5):
            if EC:
                from PythonDiffusion import eddyCorrection
                eddyCorrection(dtimg,
                               dtimg.name + '_EC',
                               protocol='eddy_correct')
            if (len(dtimg.bvals) - dtimg.nA0) / len(dtimg.dwdir) == 1:
                print "Single b-value found, but not enough directions to fit a tensor. Calculating trace image."
                dtimg.trace_1b()
                nif = nib.Nifti1Image(dtimg.trace, dtimg.affine)
                nib.save(nif, filen + '_trace.nii')
            elif (len(dtimg.bvals) - dtimg.nA0) / len(dtimg.dwdir) > 1:
                print "Multiple b-values found, but not enough directions to fit a tensor. Fitting trace image."
                dtimg.trace_multib()
                nif = nib.Nifti1Image(dtimg.trace, dtimg.affine)
                nib.save(nif, filen + '_trace.nii')

        elif os.path.isfile(dtimg.name +
                            '_EC.nii.gz') or os.path.isfile(dtimg.name +
                                                            '_EC.nii'):