Skip to content
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

Add some extra features to Siemens reader. #233

Merged
merged 29 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8ca012c
Added
Apr 26, 2024
3a980c2
Merge branch 'mind-inria:master' into master
chaithyagr Apr 26, 2024
093edfb
Fix
Apr 26, 2024
f8a6a4a
Merge branch 'master' of github.com:chaithyagr/mri-nufft
Apr 26, 2024
74c1ecd
Remove bymistake add
Apr 26, 2024
0250aa8
Fix
Apr 26, 2024
060a8bd
Fixed lint
Apr 26, 2024
aecb844
Lint
Apr 26, 2024
3130bc1
Added refbackend
Apr 26, 2024
bc014b8
Fix NDFT
Apr 26, 2024
0cc73c4
feat: use finufft as ref backend.
paquiteau Apr 29, 2024
21e090f
feat(tests): move ndft vs nufft tests to own file.
paquiteau Apr 29, 2024
6869a4a
Merge branch 'master' of github.com:mind-inria/mri-nufft
Apr 29, 2024
f8364d4
Merge branch 'master' of github.com:mind-inria/mri-nufft
Apr 30, 2024
23a63da
Merge branch 'master' of github.com:mind-inria/mri-nufft
Jun 17, 2024
3709e74
Merge branch 'master' of github.com:mind-inria/mri-nufft
Jul 1, 2024
8d6b9b4
Merge branch 'master' of github.com:chaithyagr/mri-nufft
chaithyagr Aug 1, 2024
398fb28
Merge branch 'master' of github.com:mind-inria/mri-nufft
chaithyagr Sep 5, 2024
bcf7ce3
git Merge branch 'master' of github.com:mind-inria/mri-nufft
chaithyagr Sep 19, 2024
3059ed5
Merge branch 'master' of github.com:mind-inria/mri-nufft
chaithyagr Nov 14, 2024
363774a
Merge branch 'master' of github.com:mind-inria/mri-nufft
Jan 9, 2025
0b8d97d
Merge branch 'master' of github.com:mind-inria/mri-nufft
Jan 23, 2025
df10d86
Added a bunch of extra codes
Feb 3, 2025
f280aae
PEP fixes
Feb 3, 2025
9e8010e
Update siemens.py
chaithyagr Feb 4, 2025
53cad71
Added fixes
Feb 5, 2025
12c2c6a
add [docs]
Feb 5, 2025
3f87e64
Fixes and updates on the locatuions
Feb 5, 2025
7213460
Merge branch 'master' into extract_acs
chaithyagr Feb 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/mrinufft/io/nsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ def read_arbgrad_rawdat(
if "ARBGRAD_VE11C" in data_type:
hdr["type"] = "ARBGRAD_GRE"
hdr["shifts"] = ()
for s in [7, 6, 8]:
for s in [6, 7, 8]:
shift = twixObj.search_header_for_val(
"Phoenix", ("sWiPMemBlock", "adFree", str(s))
)
Expand Down
9 changes: 8 additions & 1 deletion src/mrinufft/io/siemens.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def read_siemens_rawdat(
Imported data formatted as n_coils X n_samples X n_slices X n_contrasts
hdr: dict
Extra information about the data parsed from the twix file
This header also contains the ACS data as "acs" if it was found in raw data.

Raises
------
Expand Down Expand Up @@ -75,7 +76,12 @@ def read_siemens_rawdat(
"n_slices": int(twixObj.image.NSli),
"n_average": int(twixObj.image.NAve),
"orientation": siemens_quat_to_rot_mat(twixObj.image.slicePos[0][-4:]),
"acs": None,
}
if "refscan" in twixObj.keys():
twixObj.refscan.squeeze = True
acs = twixObj.refscan[""].astype(np.complex64)
hdr["acs"] = acs.swapaxes(0, 1)
if slice_num is not None and hdr["n_slices"] < slice_num:
raise ValueError("The slice number is out of bounds.")
if contrast_num is not None and hdr["n_contrasts"] < contrast_num:
Expand All @@ -97,7 +103,8 @@ def read_siemens_rawdat(

data = data.reshape(
hdr["n_coils"],
hdr["n_shots"] * hdr["n_adc_samples"],
hdr["n_shots"],
hdr["n_adc_samples"],
hdr["n_slices"] if slice_num is None else 1,
hdr["n_contrasts"] if contrast_num is None else 1,
hdr["n_average"] if hdr["n_average"] > 1 and not doAverage else 1,
Expand Down
27 changes: 27 additions & 0 deletions src/mrinufft/io/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,30 @@ def siemens_quat_to_rot_mat(quat):
R[2] = -R[2]
R[-1, -1] = 1
return R


def remove_extra_kspace_samples(kspace_data, num_samples_per_shot):
"""Remove extra samples from k-space data.

This function is useful when the k-space data has extra samples
mainly as ADC samples at only at specific number of samples.
This sometimes leads to a situation where we will have more ADC samples
than what is expected.

Parameters
----------
kspace_data : np.ndarray
The k-space data ordered as NCha X NShot X NSamples.
num_samples_per_shot : int
The number of samples per shot in trajectory

Returns
-------
np.ndarray
The k-space data with extra samples removed.
"""
n_samples = kspace_data.shape[-1]
n_extra_samples = n_samples - num_samples_per_shot
if n_extra_samples > 0:
kspace_data = kspace_data[..., :-n_extra_samples]
return kspace_data
Loading