diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/data_objs/image.py b/src/data_objs/image.py index a94ff4d..04aa22a 100644 --- a/src/data_objs/image.py +++ b/src/data_objs/image.py @@ -15,3 +15,11 @@ def __init__(self, scan_path: str): self.frame_rate: float # Hz self.intensities_for_analysis: np.ndarray # linearized intensity values self.extras_dict: dict = {} # dictionary for any extra information inputted by plugins + + # Visualization defaults (Moved from CeusSeg) + self.clahe_clip_limit: float = 1.2 + self.gamma: float = 1.5 + self.width_scale_axial: float = 1.0 + self.width_scale_sagittal: float = 1.0 + self.width_scale_coronal: float = 1.0 + self.use_philips_ceus: bool = False diff --git a/src/data_objs/seg.py b/src/data_objs/seg.py index c491e62..4796cc9 100644 --- a/src/data_objs/seg.py +++ b/src/data_objs/seg.py @@ -9,4 +9,3 @@ class CeusSeg: def __init__(self): self.seg_name: str self.seg_mask: np.ndarray - self.pixdim: List[float] # voxel spacing in mm diff --git a/src/image_preprocessing/__init__.py b/src/image_preprocessing/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/image_preprocessing/functions.py b/src/image_preprocessing/functions.py new file mode 100644 index 0000000..516de67 --- /dev/null +++ b/src/image_preprocessing/functions.py @@ -0,0 +1,2 @@ +from .image_preprocessors.enhance_clahe import enhance_clahe +from .image_preprocessors.enhance_gamma import enhance_gamma diff --git a/src/image_preprocessing/image_preprocessors/__init__.py b/src/image_preprocessing/image_preprocessors/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/seg_loading/README.md b/src/seg_loading/README.md index 17b2066..6970a88 100644 --- a/src/seg_loading/README.md +++ b/src/seg_loading/README.md @@ -19,10 +19,9 @@ class CeusSeg: def __init__(self): self.seg_name: str self.seg_mask: np.ndarray - self.pixdim: List[float] # voxel spacing in mm ``` -The pixel dimensions, segmentation name, and binary mask are all that must be saved in a segmentation parser. +The segmentation name and binary mask are all that must be saved in a segmentation parser. ### Plugin Structure diff --git a/src/seg_loading/seg_loaders/load_bolus_mask.py b/src/seg_loading/seg_loaders/load_bolus_mask.py index c822187..08bd2c7 100644 --- a/src/seg_loading/seg_loaders/load_bolus_mask.py +++ b/src/seg_loading/seg_loaders/load_bolus_mask.py @@ -32,7 +32,7 @@ def load_bolus_mask(image_data: UltrasoundImage, seg_path: str, **kwargs) -> Ceu out = CeusSeg() out.seg_mask = bolus_seg - out.pixdim = image_data.pixdim + if seg_path.endswith('.nii.gz'): out.seg_name = Path(seg_path).name[:-7] # Remove '.nii.gz' else: diff --git a/src/seg_loading/seg_loaders/nifti.py b/src/seg_loading/seg_loaders/nifti.py index 459dd8f..4ab60f6 100644 --- a/src/seg_loading/seg_loaders/nifti.py +++ b/src/seg_loading/seg_loaders/nifti.py @@ -19,9 +19,9 @@ def nifti(image_data: UltrasoundImage, seg_path: str, **kwargs) -> CeusSeg: out.seg_mask = np.asarray(seg.dataobj, dtype=np.uint8) if out.seg_mask.ndim == 3: # 2D + time - out.pixdim = seg.header.get_zooms()[:2] + image_data.pixdim = list(seg.header.get_zooms()[:2]) elif out.seg_mask.ndim == 4: # 3D + time - out.pixdim = seg.header.get_zooms()[:3] + image_data.pixdim = list(seg.header.get_zooms()[:3]) if seg_path.endswith('.nii.gz'): out.seg_name = Path(seg_path).name[:-7] # Remove '.nii.gz' diff --git a/src/time_series_analysis/options.py b/src/time_series_analysis/options.py index a38df06..bf8e12e 100644 --- a/src/time_series_analysis/options.py +++ b/src/time_series_analysis/options.py @@ -59,10 +59,17 @@ def get_analysis_types() -> Tuple[dict, dict]: pass functions = {} - for file in (Path(__file__).parent / "curve_types" / "curve_definitions").iterdir(): - module = importlib.import_module(f'.curve_types.curve_definitions.{file.stem}', package=__package__) - for name, obj in inspect.getmembers(module, inspect.isfunction): - if not name.startswith("_") and obj.__module__ == module.__name__: - functions[name] = obj + curve_defs_path = Path(__file__).parent / "curve_types" / "curve_definitions" + if curve_defs_path.exists(): + for file in curve_defs_path.iterdir(): + if file.suffix == ".py" and not file.name.startswith("_"): + try: + module = importlib.import_module(f'.curve_types.curve_definitions.{file.stem}', package=__package__) + for name, obj in inspect.getmembers(module, inspect.isfunction): + if not name.startswith("_") and obj.__module__ == module.__name__: + functions[name] = obj + except Exception as e: + print(f"Error loading curve definition {file.name}: {e}") + pass return types, functions