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

about feta3d_svr_test.py #4

Open
lx123-j opened this issue Apr 26, 2024 · 17 comments
Open

about feta3d_svr_test.py #4

lx123-j opened this issue Apr 26, 2024 · 17 comments

Comments

@lx123-j
Copy link

lx123-j commented Apr 26, 2024

Hello, thank you so much for sharing the code.

Regarding your code, I have a question to ask. If I need to use additional fetal brain data for reconstruction, do I need to modify feta3d_svr_test.py?

@lx123-j lx123-j changed the title RuntimeError: Could not infer dtype of NoneType about feta3d_svr_test.py Apr 26, 2024
@seannz
Copy link
Owner

seannz commented Apr 26, 2024

Hello @lx123-j

Yes, you'd need to modify the test script — what are the slice spacing and in-plane resolution of your data? You'd want to ensure the ratio between the two is around 4. (You can always re-sample each slice to satisfy this.)

@lx123-j
Copy link
Author

lx123-j commented Apr 27, 2024

Thank you very much. Can I use only one 32032018 stack with a resolution of 5mm as test data?

@seannz
Copy link
Owner

seannz commented Apr 27, 2024

Do you mean 0.5mm in-plane resolution? Or 5mm slice spacing?

@lx123-j
Copy link
Author

lx123-j commented Apr 27, 2024

5mm slice spacing.
I noticed in the test data, there's the phrase 'self.label_file = '%s_rec-%s_dseg_reg.nii.gz'. If I'm using my own dataset, do I need to provide the label_file?

@seannz
Copy link
Owner

seannz commented Apr 27, 2024

First, you'd need to re-sample the in-plane resolution to 1.25mm so that the in-plane resolution to slice spacing ratio is 1:4. The label just needs to be a foreground mask (which can just be a simple mask of non-zero pixels, for example).

@lx123-j
Copy link
Author

lx123-j commented Apr 27, 2024

Thank you very much! I'll give it a try. Do I need to maintain the 1:4 slice spacing ratio? If I were to train a new model, would it also require a 1:4 ratio?

@seannz
Copy link
Owner

seannz commented Apr 27, 2024

Ah, you can change all of these things of course if you're going to be retraining anyway. The ratio really depends on the eventual test cases you'd be working with. In my case, I was targeting mainly 0.8mm:3.0mm – 0.8mm:3.5mm acquisitions, so I chose 1:4 as the ratio. At test time, I ensure the 1:4 ratio by re-sampling each slice. (For example, the 0.8mm:3.0mm resolution slices above would be resampled to 0.75mm so that 0.75mm:3.0mm = 1:4).

@lx123-j
Copy link
Author

lx123-j commented Apr 28, 2024

I see, thank you very much!

@lx123-j
Copy link
Author

lx123-j commented May 8, 2024

Hello, sorry to bother you. When my image input is transformed into 1.251.255, with a shape of 27226118, and it is input into the flow = torch.stack([flow[:, d - 2] * ((x.shape[d] - 1)/(flow.shape[d] - 1)) for d in range(2, x.ndim)], 1) line, the shape of the images will become 13240161, causing the last loop to have a 1 which results in an error, ZeroDivisionError: division by zero. Is it because there are too few slices, only 18?

@seannz
Copy link
Owner

seannz commented May 8, 2024

The numbers above appear broken (shows as 1.251.255 and 27226118 for me) so I cannot know for sure the exact resolution and shape you are dealing with, but basically in the case of the 1:4 ratio, you'd need to replicate each slice four times before feeding the stack into the network. Have you been able to run the test script? You can step through it to see the kind of preprocessing you need to do for your own data.

@lx123-j
Copy link
Author

lx123-j commented May 8, 2024

Thank you very much for your response. My data has an in-plane resolution of 1.25 and a slice thickness of 5, with dimensions of 272, 261, 18. While running the test script, I observed that during the execution of the code segment flow = torch.stack([flow[:, d - 2] * ((x.shape[d] - 1)/(flow.shape[d] - 1)) for d in range(2, x.ndim)], 1), there is a ZeroDivisionError: division by zero error when looping to the fourth dimension because the last dimension is 18. In your response, you mentioned "you'd need to replicate each slice four times before feeding the stack into the network." Does this mean I need to convert the images to 272, 261, 72?

@seannz
Copy link
Owner

seannz commented May 8, 2024

Yes, and downsample your in-plane rest to 1mm iso. But there are other things like padding etc which will be required as well. So please refer to feta3d_svr_test.py and get your data in the same format.

@lx123-j
Copy link
Author

lx123-j commented May 8, 2024

ok, thank you very much!

@lx123-j
Copy link
Author

lx123-j commented May 17, 2024

微信图片_20240517101020

Hello,

When I replicated the third dimension of my input image four times to become 72, the reconstruction results were still not satisfactory. What could be the reason for this? Do I need to retrain a model to test it?

Thank you.

@seannz
Copy link
Owner

seannz commented May 17, 2024

Is the pre-trained model working on my data? If so, then you should work backwards to see why it doesn't work on your data. I'm not sure which dimension is considered "third", but all slices should be stacked along the D dimension in the [B C D H W] convention.

@seannz
Copy link
Owner

seannz commented May 17, 2024

Actually, if you can share a link to your data, I may be able to have a look into it, as it will be quicker that way. I can't promise anything, though.

@lx123-j
Copy link
Author

lx123-j commented May 17, 2024

MR002962_1102.nii.gz
MR002962_1102_mask.nii.gz
I am able to achieve image reconstruction using the FETA2.2 data, so the issue might be related to my data processing. I would greatly appreciate it if you could take a look at my data to see if reconstruction is possible. I am using the following two Nifti files as test data:

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

No branches or pull requests

2 participants