Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 94b40fc

Browse filesBrowse files
committed
Fixes metadata dropping
Fixes metadata-dropping bug by implementing the src/convert_to_dst_type round-trip. Fixes isort error by re-ordering imports in transforms/__init__.py. Signed-off-by: karllandheer <karllandheer@gmail.com>
1 parent 7eb60ca commit 94b40fc
Copy full SHA for 94b40fc

File tree

Expand file treeCollapse file tree

2 files changed

+13
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+13
-3
lines changed
Open diff view settings
Collapse file

‎monai/transforms/__init__.py‎

Copy file name to clipboardExpand all lines: monai/transforms/__init__.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,12 @@
200200
RandKSpaceSpikeNoised,
201201
RandKSpaceSpikeNoiseD,
202202
RandKSpaceSpikeNoiseDict,
203-
RandRicianNoised,
204-
RandRicianNoiseD,
205-
RandRicianNoiseDict,
206203
RandNonCentralChiNoised,
207204
RandNonCentralChiNoiseD,
208205
RandNonCentralChiNoiseDict,
206+
RandRicianNoised,
207+
RandRicianNoiseD,
208+
RandRicianNoiseDict,
209209
RandScaleIntensityd,
210210
RandScaleIntensityD,
211211
RandScaleIntensityDict,
Collapse file

‎monai/transforms/intensity/array.py‎

Copy file name to clipboardExpand all lines: monai/transforms/intensity/array.py
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,13 @@ def __call__(self, img: NdarrayOrTensor, randomize: bool = True) -> NdarrayOrTen
252252
"""
253253
Apply the transform to `img`.
254254
"""
255+
src = img
255256
img = convert_to_tensor(img, track_meta=get_track_meta(), dtype=self.dtype)
256257
if randomize:
257258
super().randomize(None)
258259

259260
if not self._do_transform:
261+
img, *_ = convert_to_dst_type(img, dst=src, dtype=self.dtype)
260262
return img
261263

262264
if self.channel_wise:
@@ -278,10 +280,18 @@ def __call__(self, img: NdarrayOrTensor, randomize: bool = True) -> NdarrayOrTen
278280
if not isinstance(std, (int, float)):
279281
raise RuntimeError(f"std must be a float or int number, got {type(std)}.")
280282
img = self._add_noise(img, mean=self.mean, std=std, k=self.degrees_of_freedom)
283+
284+
img, *_ = convert_to_dst_type(img, dst=src, dtype=self.dtype)
281285
return img
286+
<<<<<<< HEAD
287+
282288

283289

290+
=======
291+
284292

293+
294+
>>>>>>> 83d8ad52 (Fixes metadata dropping)
285295
class RandRicianNoise(RandomizableTransform):
286296
"""
287297
Add Rician noise to image.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.