Closed jcohenadad closed 3 months ago
I'm retracing my steps here for something I was trying to debug a few weeks ago, so I may be forgetting something ... But from what I recall, reassigning "data" seemed to fix a problem I was having (see below). I don't know why it works, but it does.
Here's what happens if I do the following:
if file_name=="acq-coilQaSagLarge_SNR_T0000": data=map.get_fdata()[round(map.get_fdata().shape[0]/2),125:385,round(map.get_fdata().shape[2]/2)] else: data=map.get_fdata()[round(map.get_fdata().shape[0]/2),:,round(map.get_fdata().shape[2]/2)]
The range along the x-axis isn't showing data from 125-385 as requested.
For some reason re-assigning the data using:
if file_name=="acq-coilQaSagLarge_SNR_T0000": data=map.get_fdata()[round(map.get_fdata().shape[0]/2),125:385,round(map.get_fdata().shape[2]/2)] data=map.get_fdata()[round(map.get_fdata().shape[0]/2),:,round(map.get_fdata().shape[2]/2)]`
results in somehow showing the data in the proper range along the x-axis:
Because you are first creating a vector of shape=260, and then you are further cropping that vector when displaying it: https://github.com/spinal-cord-7t/coil-qc-code/blob/a8dee4de63f4acffcf0294b6114a5bc13df914f0/data_processing-phantom.ipynb#L325
The solution is to either not crop the vector (ie: drop the if case at line 312) or drop the cropping of the plot (line 325)
Note: these bugs are much easier to debug when running a script and using the debugger from an IDE vs. within a jupyter notebook 😉
Ah! This is where my lack of python experience gets me into trouble. I did not realize that plt.xlim(125, 385) was cropping anything, I assumed it was only labelling ticks with a range of 125 to 385.
You mean an IDE with a python script? I would need a crash course on making the most of that, my experience as a former matlab enthusiast has not been good. I don't find it user friendly at all, but it could be because I don't know how to make the most of it.
You mean an IDE with a python script?
Yes, this is what I meant. Learning Python after having been myself a Matlab-addict, I could not program without an IDE. Examples of IDE that I've used: PyCharm and VScode. It is pretty straightforward to use and the debugger is similar to that of Matlab.
This problem has been addressed given that the code now plots the data stored in a CSV file (see https://github.com/spinal-cord-7t/coil-qc-code/blob/d2bc792c5388e0d31b4008ca177741a2d7a0f590/data_processing-phantom.ipynb#L442 and below).
If I can get a thumbs up, I'll close the issue.
https://github.com/spinal-cord-7t/coil-qc-code/blob/a8dee4de63f4acffcf0294b6114a5bc13df914f0/data_processing-phantom.ipynb#L312-L315
The variable
data
declared in the if case foracq-coilQaSagLarge_SNR_T0000
gets overwritten later. Any comment/justification that I should be aware of before addressing this issue @evaalonsoortiz ?