Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace itk with sitk bc of itk/torch mess #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cbctmc/speedup/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pathlib import Path
from typing import Tuple

import itk
import SimpleITK as sitk
import numpy as np
import torch
from ipmi.common.logger import init_fancy_logging
Expand Down Expand Up @@ -85,12 +85,12 @@ def _execute(

@staticmethod
def _load_image(filepath: PathLike) -> Tuple[np.ndarray, dict]:
image = itk.imread(filepath)
image = sitk.ReadImage(filepath)
spacing = image.GetSpacing()
origin = image.GetOrigin()
direction = image.GetDirection()

image = itk.array_from_image(image)
image = sitk.GetArrayFromImage(image)

meta = {
"spacing": spacing,
Expand Down Expand Up @@ -125,7 +125,7 @@ def execute(
batch_size=batch_size,
)

sample = itk.image_from_array(sample)
sample = sitk.GetImageFromArray(sample)
sample.SetSpacing(meta["spacing"])
sample.SetOrigin(meta["origin"])
sample.SetDirection(meta["direction"])
Expand Down
8 changes: 4 additions & 4 deletions scripts/run_mc_simulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import click
import numpy as np
import pkg_resources
import SimpleITK
import SimpleITK as sitk
import torch
import yaml
from ipmi.common.logger import init_fancy_logging
Expand Down Expand Up @@ -44,11 +44,11 @@
from cbctmc.speedup.models import FlexUNet

_DEFAULT_SEGMENTER_WEIGHTS = Path(
pkg_resources.resource_filename("cbctmc", f"assets/models/segmenter/default.pth")
pkg_resources.resource_filename("cbctmc", f"assets/weights/segmenter/default.pth")
)

_DEFAULT_SPEEDUP_WEIGHTS = Path(
pkg_resources.resource_filename("cbctmc", f"assets/models/speedup/default.pth")
pkg_resources.resource_filename("cbctmc", f"assets/weights/speedup/default.pth")
)


Expand Down Expand Up @@ -584,7 +584,7 @@ def run(
/ config_name
/ "projections_total_normalized_speedup.mha"
)
itk.imwrite(speedup_projections, str(speedup_projections_filepath))
sitk.WriteImage(speedup_projections, str(speedup_projections_filepath))

if not dry_run:
reconstruct_4d = is_4d and reconstruct_4d
Expand Down