Skip to content

Commit

Permalink
change kwargs in put for basesubjectwriter
Browse files Browse the repository at this point in the history
Former-commit-id: a9f093c
Former-commit-id: e7747e4a255aa0b53f5788d92db01b1ac4df2b32
  • Loading branch information
fishingguy456 committed May 19, 2022
1 parent 9a4509b commit cd886d2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions imgtools/io/writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,17 @@ def __init__(self, root_directory, filename_format="{subject_id}.nii.gz", create
shutil.rmtree(os.path.dirname(self.root_directory))
print(self.root_directory)

def put(self, subject_id, image, **kwargs):
if kwargs["is_mask"]:
self.filename_format = kwargs["mask_label"]+".nii.gz"
def put(self, subject_id, image, is_mask=False, mask_label="",**kwargs):
if is_mask:
self.filename_format = mask_label+".nii.gz"
out_path = self._get_path_from_subject_id(subject_id, **kwargs)
sitk.WriteImage(image, out_path, self.compress)

def _get_path_from_subject_id(self, subject_id, **kwargs):
out_filename = self.filename_format.format(subject_id=subject_id,
**kwargs)
# out_filename = self.filename_format.format(subject_id=subject_id, **kwargs)
self.root_directory = self.root_directory.format(subject_id=subject_id,
**kwargs)
out_path = os.path.join(self.root_directory, out_filename)
out_path = os.path.join(self.root_directory, self.filename_format)
out_dir = os.path.dirname(out_path)
if self.create_dirs and not os.path.exists(out_dir):
os.makedirs(out_dir, exist_ok=True) # create subdirectories if specified in filename_format
Expand Down

0 comments on commit cd886d2

Please sign in to comment.