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 average and fix bug for cartesian data #166

Merged
merged 3 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions src/mrinufft/io/nsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ def read_trajectory(
def read_arbgrad_rawdat(
filename: str,
removeOS: bool = False,
doAverage: bool = True,
squeeze: bool = True,
slice_num: int | None = None,
contrast_num: int | None = None,
Expand All @@ -417,6 +418,8 @@ def read_arbgrad_rawdat(
The path to the Siemens MRI file.
removeOS : bool, optional
Whether to remove the oversampling, by default False.
doAverage : bool, optional
Whether to average the data acquired along NAve dimension, by default True.
squeeze : bool, optional
Whether to squeeze the dimensions of the data, by default True.
slice_num : int, optional
Expand Down Expand Up @@ -447,6 +450,7 @@ def read_arbgrad_rawdat(
data, hdr, twixObj = read_siemens_rawdat(
filename=filename,
removeOS=removeOS,
doAverage=doAverage,
squeeze=squeeze,
slice_num=slice_num,
contrast_num=contrast_num,
Expand Down
8 changes: 7 additions & 1 deletion src/mrinufft/io/siemens.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
def read_siemens_rawdat(
filename: str,
removeOS: bool = False,
doAverage: bool = True,
squeeze: bool = True,
return_twix: bool = True,
slice_num: int | None = None,
Expand All @@ -21,6 +22,8 @@ def read_siemens_rawdat(
The path to the Siemens MRI file.
removeOS : bool, optional
Whether to remove the oversampling, by default False.
doAverage : bool, option
Whether to average the data acquired along NAve dimension.
squeeze : bool, optional
Whether to squeeze the dimensions of the data, by default True.
data_type : str, optional
Expand Down Expand Up @@ -61,12 +64,14 @@ def read_siemens_rawdat(
if isinstance(twixObj, list):
twixObj = twixObj[-1]
twixObj.image.flagRemoveOS = removeOS
twixObj.image.flagDoAverage = doAverage
hdr = {
"n_coils": int(twixObj.image.NCha),
"n_shots": int(twixObj.image.NLin),
"n_shots": int(twixObj.image.NLin) * int(twixObj.image.NPar),
"n_contrasts": int(twixObj.image.NSet),
"n_adc_samples": int(twixObj.image.NCol),
"n_slices": int(twixObj.image.NSli),
"n_average": int(twixObj.image.NAve),
}
if slice_num is not None and hdr["n_slices"] < slice_num:
raise ValueError("The slice number is out of bounds.")
Expand All @@ -92,6 +97,7 @@ def read_siemens_rawdat(
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,
)
if return_twix:
return data, hdr, twixObj
Expand Down
Loading