bvbabel icon indicating copy to clipboard operation
bvbabel copied to clipboard

Potentional Better Matrix Reader?

Open ChengranAA opened this issue 2 years ago • 1 comments

Hi Faruk:

In the read_fmr function, I have notice your note:

# NOTE(Faruk): I dont like this matrix reader but I don't see a
# more elegant way for now.

From what I have researched and tested (only slice timings' code is shown here):

slice_timings = np.ndarray.tolist(np.fromstring(''.join(lines[j + 1 : j + 1 + int(content[1])]), sep='\n'))
info_multiband["Slice timings"] = slice_timings

This could potentially replace the original method. The logic is, since numpy is a dependency of bvbabel, we can use their fromstring function to convert text data into 1D array. This way we could avoid using two loops for reading affine and slice timings arrays. I have tested on the data I have, and compared to the original method, I printed out their slice timing array, and they seems identical. I think this is an indication that this method is working.

If this catches your eyes, I can make a pull request.

Thank you very much!

ChengranAA avatar Dec 10 '23 07:12 ChengranAA

Hi @ChengranAA , thanks for opening this issue, looks promising. You can make a pull request. When doing, please indicate why this method is better compared to the previous one.

ofgulban avatar Dec 13 '23 13:12 ofgulban