-
Notifications
You must be signed in to change notification settings - Fork 25
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
Loading shows different behavioural on different datasets #6
Comments
Hi @Sins-code Are there any odd characters in the filename of the file you pass in for the second scan. In pdb can you step through and see where the errors occur and what the values of mem[k] + szScanHeader are? |
Greetings @wexeee, im glad you found the time to answer my question, many thanks! The Filenames i'm passing are for example: meas_MID00102_FID31136_t2_tse11_tra_256_4mm.dat -> works and meas_MID00040_FID08032_REF_EPI1_256x244x44_TE6_TR580.dat -> does not work! |
The error happens right after executing twixObj.image[''], when calling fid.seek(mem[k] + scanHeader, 0) in the method readData. Values are: k=0, kmax=27456, mem[0] has the value: -2147439168 and szScanHeader has value 192. |
I think that mem[0] being < 0 doesn't make sense, it is trying to set the position to before the start of the file. Can you trace that back through the code to see why that occurs? |
Perhaps see if it is an artefact of this line: https://github.com/wexeee/pymapvbvd/blob/3300290f3d626dc4c9305e326c0ea453ff5c90f6/mapvbvd/twix_map_obj.py#L681 where there is some casting. |
I checked getitem right now: 1 mem = self.memPos[ixToRaw] This is the first time readData is called! But already in line 1 there are some big negative values stored quite at the end of the array mem, which get to the front after being sorted in in line 3. I will check memPos now! |
Thanks. Yes, that is calculated via the filePos variable set here. https://github.com/wexeee/pymapvbvd/blob/3300290f3d626dc4c9305e326c0ea453ff5c90f6/mapvbvd/mapVBVD.py#L353 |
The error happens somewhere in here: After this while loop the are some negative values in the filePos-array! The negative values start to appear in iteration 25942, before that everything is normal. Max positive value is in iteration 25941 with value 2147445376.00, then everything gets negative, value in iteration 25942 is -2147439168.00! It seems to me like a numpy int32 overflow! |
@wexeee What is your opinion on my explanation for the problem? |
That sound possible (hence my incorrect guess with the explicit cast above). What type is being used here? I thought python was fairly good at handling things like this. I've also had issues with (matlab) mapVBVD before where mdh loop parameters were centred around zero rather than just incrementing from zero. That isn't happening here is it? |
Seems like I was on the wrong path...filePos has dtype float64, which is big enough ^^ i should have checked that first. I'm looking for other errors now! |
Seems like i found the error now! My debugger tells me that the variable cpos, which is used to fill filePos, is from type int32! |
So fid.tell() returns an int32? What OS are you on? |
Yeah exactly. Windows 10! Using Python 3.8.10. |
And does the negative number come from fid.tell() or some calculation applied to the cpos variable? |
Im trying to find out, running some more tests, give me a second! |
It happens in between, directly in the first iteration! cpos starts as an (unlimited?) int, then becomes an int32 exactly here, at the end of the while loop: |
Ah, probably something to do with the numpy types of the vairables feeding into ulDMALength. Does |
Yes it does! 👍 |
Great. Could you make a PR with this fix in? I can then check out some of the tests with it. |
I still have one general question: For example here the loading goes super fast: pymapVBVD version 0.4.1 read data: 0%| | 0/15660 [00:00<?, ?it/s] Whereas here it goes really slow: pymapVBVD version 0.4.1 read data: 0%| | 0/27456 [00:00<?, ?it/s] Do you have an explanation for this? :D |
Of course I can. But I will have to learn how to do it first, since I'm new to github! |
I have now merged this fix. |
Hello @ALL,
im doing scientific research about coil compression possibilities. To be able to do everything in just one programming language, i decided to use this module instead of importing some matlab-functionalities to python.
While working i found an error i can't really explain to myself:
I work with to different .dat MRI-files, 1) with dimensions (256, 20, 261, 1, 20, 1, 1, 1, 3, 1, 9, 1, 1, 1, 1, 1) and 2) with dimensions (256, 20,208, 1, 44, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1) after removing oversampling. Both times i want to load the whole dataset in the beginning with data = twixObj.image[''] . But this works just for dataset 1. If i use this on the second dataset, i get this error-message:
line 23, in data = twixObj.image['']
line 646, in getitem out = self.readData(mem, ixToTarg, ixToRaw, selRange, selRangeSz, outSize)
line 748, in readData fid.seek(mem[k] + szScanHeader, 0)
OSError: [Errno 22] Invalid argument
If i use for example this command data= twixObj.image[:,:,:,:,20] , the loading works...but i can never load the whole data-set 2!
Any ideas why this happens? If you want, i can try to share the dataset which does not work well with the module on some platform, so you can reproduce the error.
Many thanks
The text was updated successfully, but these errors were encountered: