Replies: 4 comments 2 replies
-
Hi @kretes, could you please share a small script I can help debug? I can't reproduce using the code below.
Thanks! |
Beta Was this translation helpful? Give feedback.
-
Yes, your script works (although I needed to add However, if you switch the order of tensors that are passed to
Which is as well an API glitch, since it should be equivariant . |
Beta Was this translation helpful? Give feedback.
-
also instead of changing MONAI/monai/transforms/croppad/array.py Lines 701 to 705 in fabc198 |
Beta Was this translation helpful? Give feedback.
-
thanks for raising the issue, we added some logic to identify common meta dictionary keys. #7054 |
Beta Was this translation helpful? Give feedback.
-
I stumbled upon a case when using a custom data transform pipeline.
Background:
I am using a custom strategy of sampling data, where for some data points I use
RandCropByPosNegLabeld
while for some -RandSpatialCropd
the problem is that
RandCropByPosNegLabeld
adds some new fields to metadata ('patch_index' and 'crop_center'), that I don't get fromRandSpatialCropd
.And so I get errors from collate mechanism, that seems to be hierarchical, and strict in terms of the structure.
The traceback
It wasn't very obvious for me at first what's going on and I spent some time to debug this issue.
The problem gets more complicated, as collate mechanism takes the first element from the batch to infer and expect the structure and so in some batches it worked ok, while in other it didn't.
I am not sure about the solution for this, but I think monai should offer something more.
First of all I am thinking about some decent structure checking, e.g. to show the hierarchical aspect of this situation.
It would be nice to get an exception like 'Different structures in batch elements. batch element 0 has image.meta.patch_index, while batch element 2 is missing'
Additional thing is that
RandCropByPosNegLabeld
doesn't say explicitly in the doc that such keys will be added, and so the user needs to dig through source code / check empirically.I have the workaround, which is to add at least the same structure in the other branch of code:
but this seems hairy and will not generalize into similar cases
Beta Was this translation helpful? Give feedback.
All reactions