Skip to content

2304 enhances image dataset to handle meta#2308

Merged
wyli merged 2 commits intoProject-MONAI:devfrom
wyli:2304-enhance-meta
Jun 5, 2021
Merged

2304 enhances image dataset to handle meta#2308
wyli merged 2 commits intoProject-MONAI:devfrom
wyli:2304-enhance-meta

Conversation

@wyli
Copy link
Copy Markdown
Contributor

@wyli wyli commented Jun 4, 2021

Signed-off-by: Wenqi Li [email protected]

Fixes #2304

Description

adds a transform_with_metadata to ImageDataset

Status

Ready

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • New tests added to cover the changes.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

Signed-off-by: Wenqi Li <[email protected]>
@Nic-Ma
Copy link
Copy Markdown
Contributor

Nic-Ma commented Jun 4, 2021

Hi @wyli ,

Thanks for your enhancement for ImageDataset.
I think the reason we kept ImageDataset after developed ArrayDataset is that: ImageDataset loads image data and meta_data in this dataset instead of transforms, so it can apply following typical transform chain only for the image data and still return both transformed image data and the meta_data.
For the use case you provided in this PR, it requires every transform in the chain must accept the meta_data arg, then why not use ArrayDataset directly?
And to support mixed transforms that some can accept meta_data and some not, users can refer to this example:
https://github.com/Project-MONAI/MONAI/blob/dev/monai/data/dataset.py#L926
What do you think?

Thanks.

@wyli
Copy link
Copy Markdown
Contributor Author

wyli commented Jun 4, 2021

Hi @Nic-Ma, this API is used by multiple tutorials, but it's half baked. here I enhanced it and made a demo to show the usage. Project-MONAI/tutorials#222

@Nic-Ma
Copy link
Copy Markdown
Contributor

Nic-Ma commented Jun 4, 2021

Hi @wyli ,

Thanks for your tutorial, may I know why we don't use ArrayDataset for the case in the tutorial? Maybe you can change to show ArrayDataset in the tutorial?
I think we only use ImageDataset in the case that we need the meta_data for the following operations(like saving files) and all the transforms don't need meta_data, otherwise, ArrayDataset may be a better choice.

Thanks.

@wyli
Copy link
Copy Markdown
Contributor Author

wyli commented Jun 4, 2021

with this enhancement the imagedataset has better handling of the metadata compared with the arraydataset, now it's a good complimentary to our dataset APIs

@Nic-Ma
Copy link
Copy Markdown
Contributor

Nic-Ma commented Jun 4, 2021

Hi @wyli ,

I don't quite understand "ImageDataset has better handling of the metadata compared with the ArrayDataset", could you please help share more details?
I think we discussed to use ArrayDataset and delete ImageDataset, but ImageDataset has 1 benefit that can get both image data and meta_data but only run transform chain on the image data, so we keep it.

Thanks.

@wyli
Copy link
Copy Markdown
Contributor Author

wyli commented Jun 4, 2021

the current imagedataset doesn't work with the meta data as reported in #2304, this PR fixes the issue.

@Nic-Ma
Copy link
Copy Markdown
Contributor

Nic-Ma commented Jun 4, 2021

OK, I see your point now.
So you mean to support the case that: all the transforms in the Compose chain expect (img, meta) input and ArrayDataset can't support this case if using Compose, right?
That makes sense.

Thanks for your explanation.

@wyli wyli merged commit 2ff528e into Project-MONAI:dev Jun 5, 2021
@wyli wyli deleted the 2304-enhance-meta branch June 5, 2021 17:48
This was referenced Jun 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spacing transforms scale pixel dimensions or resample to specified pixel dimensions

2 participants