wtclarke / pymapvbvd

Python port of mapVBVD
MIT License
40 stars 25 forks source link

Have the same issue but different reasons to #6 #28

Closed JinhoKim46 closed 1 year ago

JinhoKim46 commented 1 year ago

Hello,

I have the same error as #6, but for a different reason.

I saw that you modified the code in mapVBVD.py to cPos = cPos + int(ulDMALength). Since I installed the mapVBVD tool after you push this modification, my mapVBVD module does have the modified code in mapVBVD.py.

However, I have the same error when I run obj[''] and the error shows like

read data: 48%|████▊ | 5954/12342 [00:05<00:07, 900.44it/s]C:\Users\z0048drc\AppData\Local\miniconda3\envs\Work-ismrmrd\lib\site-packages\mapvbvd\twix_map_obj.py:766: RuntimeWarning: invalid value encountered in add raw = (raw[:, 0] + 1j * raw[:, 1]).reshape(readShape, order='F') Traceback (most recent call last): File "C:\Program Files\JetBrains\PyCharm 2022.3.2\plugins\python\helpers\pydev\pydevd.py", line 1496, in _exec pydev_imports.execfile(file, globals, locals) # execute the script File "C:\Program Files\JetBrains\PyCharm 2022.3.2\plugins\python\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "C:\Users\z0048drc\Documents\Github\cinevn-helpers-master\cinevn-helpers-master\test.py", line 20, in kdata = obj[''] File "C:\Users\z0048drc\AppData\Local\miniconda3\envs\Work-ismrmrd\lib\site-packages\mapvbvd\twix_map_obj.py", line 657, in getitem out = self.readData(mem, ixToTarg, ixToRaw, selRange, selRangeSz, outSize) File "C:\Users\z0048drc\AppData\Local\miniconda3\envs\Work-ismrmrd\lib\site-packages\mapvbvd\twix_map_obj.py", line 759, in readData fid.seek(mem[k] + szScanHeader, 0) OSError: [Errno 22] Invalid argument

I found that the reason for this error was very large negative values in mem variable. Actually, mem is passed to readData() in txiw_map_obj.py from __getitem__() with positive values, but in float64 data type. Based on the current installation version (2023.02.20), the code at Line 638, mem = mem.astype(int) causes memory overflow resulting in very large values.

There are two screenshots showing these results. 2023-02-21 22_13_49-Evaluate 2023-02-21 22_13_38-Evaluate

The first one shows memory overflow, and the second is mem passed from __getitem()__.

How can I handle this problem?

Interestingly, the Siemens raw file contains two scans, ref scan and the main scan. When I try to extract the image for the ref scan, which is quite small data, then the error has not occurred.

Thanks a lot in advance!

JinhoKim46 commented 1 year ago

I found a workaround for this problem.

In readData() method in twix_map_obj.py, mem was defined as mem.astype(int), which results in int32 datatype, and int32 causes memory overflow for the large dataset. So, I changed the line to np.int64(mem) to increase the capacity to hold a larger dataset, and the error disappeared.