Example #1
0
 def _run_interface(self, runtime):
     niis = [nb.load(fn) for fn in self.inputs.in_files]
     nws = [NiftiWrapper(nii, make_empty=True) for nii in niis]
     if self.inputs.sort_order:
         sort_order = self.inputs.sort_order
         if isinstance(sort_order, (str, bytes)):
             sort_order = [sort_order]
         nws.sort(key=make_key_func(sort_order))
     if self.inputs.merge_dim == traits.Undefined:
         merge_dim = None
     else:
         merge_dim = self.inputs.merge_dim
     merged = NiftiWrapper.from_sequence(nws, merge_dim)
     const_meta = merged.meta_ext.get_class_dict(("global", "const"))
     self.out_path = self._get_out_path(const_meta)
     nb.save(merged.nii_img, self.out_path)
     return runtime
Example #2
0
 def _run_interface(self, runtime):
     niis = [nb.load(fn) for fn in self.inputs.in_files]
     nws = [NiftiWrapper(nii, make_empty=True) for nii in niis]
     if self.inputs.sort_order:
         sort_order = self.inputs.sort_order
         if isinstance(sort_order, str):
             sort_order = [sort_order]
         nws.sort(key=make_key_func(sort_order))
     if self.inputs.merge_dim == traits.Undefined:
         merge_dim = None
     else:
         merge_dim = self.inputs.merge_dim
     merged = NiftiWrapper.from_sequence(nws, merge_dim)
     const_meta = merged.meta_ext.get_class_dict(("global", "const"))
     self.out_path = self._get_out_path(const_meta)
     nb.save(merged.nii_img, self.out_path)
     return runtime
Example #3
0
	src = join(home, '.dipy', subject + '_b0_AP.nii.gz') # Where the source file is
	dst = join(dname, subject + "_b0_AP.nii.gz") # The new destination for the file
	shutil.move(src, dst) # Moving the file to the right directory

	#############################################################
	#                        Merging                            #
	#############################################################
	fb0AP = join(dname, subject + '_b0_AP.nii.gz') # The b0AP image is saved in this variable
	fb0PA = join(dname, subject + '_DWI_b0_PA.nii.gz') # The b0PA image is saved in this variable
	b0AP = NiftiWrapper.from_filename(fb0AP) # Loading the image in this variable
	b0PA = NiftiWrapper.from_filename(fb0PA) # Loading the image in this variable
	print(b0AP.nii_img.get_shape()) # Size of data
	print(b0PA.nii_img.get_shape()) # Size of data
	print(b0AP.get_meta('EchoTime')) # Echo time
	print(b0PA.get_meta('EchoTime')) # Echo time
	b0APPA = NiftiWrapper.from_sequence([b0AP, b0PA]) # Merging of the two b0 files
	print(b0APPA.nii_img.get_shape()) # Size of data
	print(b0APPA.get_meta('EchoTime', index = (0, 0, 0, 0))) # Echo time
	print(b0APPA.get_meta('EchoTime', index = (0, 0, 0, 1))) # Echo time

	#############################################################
	# 						Topup								#
	#############################################################


	#############################################################
	#	 		 	  Brain Extraction Tool (BET)				#
	#############################################################
	topb0 = join(dname, subject + '_topup_b0.nii.gz') # The topup_b0 file is saved in this variable
	img = nib.load (topb0) # Saving the nifti image in this variable