Skip to content
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
2 changes: 1 addition & 1 deletion dosma/core/numpy_routines.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def nan_to_num(x, copy=True, nan=0.0, posinf=None, neginf=None):
return x._partial_clone(volume=vol)


@implements(np.around, np.round, np.round_)
@implements(np.around, np.round, np.round)
def around(x, decimals=0, affine=False):
"""Round medical image pixel data (and optionally affine) to the given number of decimals.

Expand Down
2 changes: 1 addition & 1 deletion dosma/models/model_loading_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def _gen_mask(func, *_args, **_kwargs):

if isinstance(cfg_file_or_dict, str):
with open(cfg_file_or_dict, "r") as f:
cfg = yaml.load(f)
cfg = yaml.load(f, Loader=yaml.FullLoader)
else:
cfg = cfg_file_or_dict

Expand Down
4 changes: 4 additions & 0 deletions dosma/models/oaiunet2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,15 @@ def __load_keras_model__(self, input_shape, force_weights=False):
padding="same",
activation="relu",
kernel_initializer="he_normal",
name=f"conv2d_down_{depth_cnt}_1" # Unique name for each layer
)(pool)
conv = Conv2D(
nfeatures[depth_cnt],
(3, 3),
padding="same",
activation="relu",
kernel_initializer="he_normal",
name=f"conv2d_down_{depth_cnt}_2" # Unique name for each layer
)(conv)

conv = BN(axis=-1, momentum=0.95, epsilon=0.001)(conv)
Expand Down Expand Up @@ -134,13 +136,15 @@ def __load_keras_model__(self, input_shape, force_weights=False):
padding="same",
activation="relu",
kernel_initializer="he_normal",
name=f"conv2d_up_{depth_cnt}_1" # Unique name for each layer
)(up)
conv = Conv2D(
nfeatures[depth_cnt],
(3, 3),
padding="same",
activation="relu",
kernel_initializer="he_normal",
name=f"conv2d_up_{depth_cnt}_2" # Unique name for each layer
)(conv)

conv = BN(axis=-1, momentum=0.95, epsilon=0.001)(conv)
Expand Down
16 changes: 12 additions & 4 deletions dosma/scan_sequences/mri/qdess.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def generate_t2_map(
tissue: Tissue = None,
suppress_fat: bool = False,
suppress_fluid: bool = False,
b1map: MedicalVolume = None,
beta: float = 1.2,
gl_area: float = None,
tg: float = None,
Expand Down Expand Up @@ -211,9 +212,16 @@ def generate_t2_map(

# Flip Angle (degree -> radians)
alpha = float(ref_dicom.FlipAngle) if alpha is None else alpha
alpha = math.radians(alpha)
if np.allclose(math.sin(alpha / 2), 0):
warnings.warn("sin(flip angle) is close to 0 - t2 map may fail.", stacklevel=2)

if b1map:
alpha_nominal = deepcopy(alpha)
alpha = np.multiply(b1map.volume, math.radians(alpha))
if np.allclose(np.sin(alpha_nominal / 2), 0):
warnings.warn("sin(flip angle) is close to 0 - t2 map may fail.")
else:
alpha = math.radians(alpha)
if np.allclose(math.sin(alpha / 2), 0):
warnings.warn("sin(flip angle) is close to 0 - t2 map may fail.")

mask = xp.ones([r, c, num_slices])

Expand Down Expand Up @@ -244,7 +252,7 @@ def generate_t2_map(
/ (1 - xp.cos(alpha) * xp.exp(-TR / T1))
)
c1 = 0

# have to divide division into steps to avoid overflow error
t2map = -2000 * (TR - TE) / (xp.log(abs(ratio) / k) + c1)
t2map = xp.nan_to_num(t2map)
Expand Down