About resampling it back

Hi, I have generated numpy binary mask arrays with dimensions 144144144, but I am having trouble resampling it back. I saved the array to nii.gz by:

file_image = nib.Nifti1Image(file_array, affine=np.eye(4))

and use the given cli_resampling_back.py to restore resolutions. I followed the instruction and extracted the original resolution to a csv:

,PatientID,resolution_x,resolution_y,resolution_z,Resolution_x,Resolution_y,Resolution_z

0,CHUV001,1.3671879768371582,1.3671879768371582,3.2699999809265137

1,CHUV002,1.3671879768371582,1.3671879768371582,3.2699999809265137

2,CHUV003,1.3671879768371582,1.3671879768371582,3.2699999809265137

3,CHUV004,1.3671879768371582,1.3671879768371582,3.2699999809265137

4,CHUV005,1.3671879768371582,1.3671879768371582,3.2699999809265137

5,CHUV006,1.3671879768371582,1.3671879768371582,3.2699999809265137

6,CHUV007,1.3671879768371582,1.3671879768371582,3.2699999809265137

7,CHUV008,1.3671879768371582,1.3671879768371582,3.2699999809265137

8,CHUV009,1.3671879768371582,1.3671879768371582,3.2699999809265137

9,CHUV010,1.3671879768371582,1.3671879768371582,3.2699999809265137

10,CHUV011,1.3671879768371582,1.3671879768371582,3.2699999809265137

11,CHUV012,0.9765620231628418,0.9765620231628418,4.25

12,CHUV013,0.9765620231628418,0.9765620231628418,4.25

13,CHUV014,0.9765620231628418,0.9765620231628418,4.25

14,CHUV015,0.9765620231628418,0.9765620231628418,4.25

15,CHUV016,0.9765620231628418,0.9765620231628418,4.25

16,CHUV017,0.9765620231628418,0.9765620231628418,1.25

17,CHUV018,0.9765620231628418,0.9765620231628418,1.25

18,CHUV019,0.9765620231628418,0.9765620231628418,1.25

19,CHUV020,0.9765620231628418,0.9765620231628418,3.2699999809265137

20,CHUV021,0.9765620231628418,0.9765620231628418,3.2699999809265137

21,CHUV022,1.3671879768371582,1.3671879768371582,3.2699999809265137

22,CHUV023,1.3671879768371582,1.3671879768371582,3.2699999809265137

23,CHUV024,1.3671879768371582,1.3671879768371582,3.2699999809265137

24,CHUV025,1.3671879768371582,1.3671879768371582,3.2699999809265137

25,CHUV026,1.3671879768371582,1.3671879768371582,3.2699999809265137

26,CHUV027,1.3671879768371582,1.3671879768371582,3.2699999809265137

27,CHUV028,1.3671879768371582,1.3671879768371582,3.2699999809265137

28,CHUV029,1.3671879768371582,1.3671879768371582,3.2699999809265137

29,CHUV030,0.9765620231628418,0.9765620231628418,1.0

30,CHUV031,1.3671879768371582,1.3671879768371582,3.2699999809265137

31,CHUV032,1.3671879768371582,1.3671879768371582,3.2699999809265137

32,CHUV033,0.9765620231628418,0.9765620231628418,3.2699999809265137

33,CHUV034,1.3671879768371582,1.3671879768371582,3.2699999809265137

34,CHUV035,1.3671879768371582,1.3671879768371582,3.2699999809265137

35,CHUV036,0.9765620231628418,0.9765620231628418,1.0

36,CHUV037,1.3671879768371582,1.3671879768371582,3.2699999809265137

37,CHUV038,1.3671879768371582,1.3671879768371582,3.2699999809265137

38,CHUV039,1.3671879768371582,1.3671879768371582,3.2699999809265137

39,CHUV040,1.3671879768371582,1.3671879768371582,3.2699999809265137

40,CHUV041,1.3671879768371582,1.3671879768371582,3.2699999809265137

41,CHUV042,1.3671879768371582,1.3671879768371582,3.2699999809265137

42,CHUV043,1.3671879768371582,1.3671879768371582,3.2699999809265137

43,CHUV044,1.3671879768371582,1.3671879768371582,3.2699999809265137

44,CHUV045,1.3671879768371582,1.3671879768371582,3.2699999809265137

45,CHUV046,1.3671879768371582,1.3671879768371582,3.2699999809265137

46,CHUV047,0.9765620231628418,0.9765620231628418,1.0

47,CHUV048,0.9765620231628418,0.9765620231628418,1.0

48,CHUV049,1.3671879768371582,1.3671879768371582,3.2699999809265137

49,CHUV050,1.3671879768371582,1.3671879768371582,3.2699999809265137

50,CHUV051,1.3671879768371582,1.3671879768371582,3.2699999809265137

51,CHUV052,1.3671879768371582,1.3671879768371582,3.2699999809265137

52,CHUV053,0.9765620231628418,0.9765620231628418,1.0

But when I submitted the files, it always tells me the masks are not binary or not resampled back. I am stuck at the last step, and hopeful someone can help me please.

Hi,

I updated the code on github, there was an issue with the naming of the file. The resampler looked wether the string ‘gtv’ was present in the name to decide which resampling method to apply and if it was not present it used the cubic spline interpolation leading to non-binary masks. The updated code now always applies nearest neighbor interpolation when calling cli_resampling_back.py.
I hope it will fix your issue.
Best,

Valentin

I am still facing the same issue.
I have generated the binary masks of 144144144.
Saved the file and got the original resolutions with the script provided and then resampled it with cli_resampling_back.py script(used the latest script from github).
But post re-sampling back I am getting irregular shapes as (105, 105, 44) or (147, 147, 33).
Even the binary masks from predictions are being nullified to zero(Predicted values [0,1],after re-sampling (only [0]))

If anyone could tell me where am I going wrong?