def _run_interface(self, runtime):
in_file = nb.load(self.inputs.in_file)
wm_mask = nb.load(self.inputs.wm_mask).get_data()
wm_mask[wm_mask < 0.9] = 0
wm_mask[wm_mask > 0] = 1
wm_mask = wm_mask.astype(np.uint8)
if self.inputs.erodemsk:
# Create a structural element to be used in an opening operation.
struc = nd.generate_binary_structure(3, 2)
# Perform an opening operation on the background data.
wm_mask = nd.binary_erosion(wm_mask, structure=struc).astype(np.uint8)
data = in_file.get_data()
data *= 1000.0 / np.median(data[wm_mask > 0])
out_file = fname_presuffix(self.inputs.in_file,
suffix='_harmonized', newpath='.')
in_file.__class__(data, in_file.affine, in_file.header).to_filename(
out_file)
self._results['out_file'] = out_file
return runtime
评论列表
文章目录