Skip to content

Commit

Permalink
update segments to support multi-label nifti files from dcmqi export
Browse files Browse the repository at this point in the history
  • Loading branch information
LennyN95 committed Jul 15, 2024
1 parent 507776c commit c070af3
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/pydcmqi/segimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ def _triplet_setter(self, key: str, value: Union[Tuple[str, str, str], Triplet])
value = Triplet.fromTuple(value)
assert isinstance(value, Triplet)
self._data[key] = value.asdict()


@property
def segmentedPropertyCategory(self) -> Triplet:
Expand Down Expand Up @@ -539,9 +538,9 @@ def config(self) -> Optional[Path]:
class SegImage:
verbose: bool = False

@staticmethod
def reset() -> None:
SegImage.verbose = False
@classmethod
def reset(cls) -> None:
cls.verbose = False

def __init__(
self, verbose: Optional[bool] = None, tmp_dir: Optional[Union[Path, str]] = None
Expand Down Expand Up @@ -631,16 +630,17 @@ def _import(

# load each segmentation as item
for i, s in enumerate(self._config["segmentAttributes"]):
assert len(s) == 1
config = s[0]
labeID = int(config["labelID"])

# find generated export file
f = os.path.join(output_dir, f"pydcmqi-{i+1}.nii.gz")

# create new segment
segment = self.new_segment()
segment.setFile(f, labeID, disable_file_sanity_checks)
segment.config = config
# load all configs from segment definition
for config in s:
labeID = int(config["labelID"])

# create new segment
segment = self.new_segment()
segment.setFile(f, labeID, disable_file_sanity_checks)
segment.config = config

# update state
self.loaded = True
Expand Down

0 comments on commit c070af3

Please sign in to comment.