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

MT/ihMT scripts: cleanup and adding B1+ correction #870

Merged
merged 57 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
5cb827b
WIP
Dec 7, 2023
2b3fcef
WIP
Dec 7, 2023
04372c4
WIP
Dec 7, 2023
5c173ba
WIP
karanphil Dec 8, 2023
344af2f
Adding B1 correction
karanphil Dec 8, 2023
b76e3c1
Removing clip B1
karanphil Dec 8, 2023
4111d99
WIP
karanphil Dec 10, 2023
5bd3f76
WIP
karanphil Dec 10, 2023
1f88691
WIP
karanphil Dec 10, 2023
d8e143a
WIP
karanphil Dec 10, 2023
0c5bb72
Adding header correction scripts
karanphil Dec 10, 2023
26d7880
Fixing assert
karanphil Dec 10, 2023
8d5fbf3
WIP
karanphil Dec 12, 2023
3a0b00f
WIP
karanphil Dec 14, 2023
a5d85a6
Merge branch 'master' of github.com:scilus/scilpy into b1_correction
karanphil Dec 14, 2023
4904a6a
Updating doc for ihmt script
karanphil Dec 14, 2023
3fe671f
WIP on parser
karanphil Dec 14, 2023
2abe00e
WIP update ihmt script
karanphil Dec 14, 2023
0196394
Big cleanup of scil_mti_maps_ihMT.py
karanphil Dec 15, 2023
471658d
Fixing help
karanphil Dec 15, 2023
05e4ee1
Finishing cleanup of ihMT script
karanphil Dec 15, 2023
fedbb4b
Fixing ihMT script
karanphil Dec 15, 2023
fef9a79
Fixing ihMT script and starting MT script
karanphil Dec 15, 2023
f0391d6
Updating MT script
karanphil Dec 15, 2023
e2cf7d1
Updating MT script works
karanphil Dec 15, 2023
fbaeae5
Last remaining bug comment
karanphil Dec 15, 2023
5b6baaf
Removing unused function
karanphil Dec 15, 2023
8e23270
Fixing pep 8
karanphil Dec 15, 2023
2440112
Fixing pep 8
karanphil Dec 15, 2023
c02607e
Small modifs to correction
karanphil Dec 16, 2023
8557fe5
WIP
Jan 9, 2024
b5170ce
Removing shift from B1
karanphil Jan 10, 2024
e686614
Pull master
Jan 11, 2024
4420c70
Fixing conflicts
Jan 11, 2024
820db5d
Adding and fixing tests
Jan 11, 2024
289e18c
Merge branch 'master' of github.com:karanphil/scilpy into b1_correction
Jan 15, 2024
db32441
Merge branch 'master' of github.com:scilus/scilpy into b1_correction
Jan 25, 2024
5568b60
Adding tests for mti_maps_MT
Jan 25, 2024
dfbf04e
Adding tests to mti_maps_ihMT
Jan 25, 2024
89c0bab
Adding --in_jsons in docs
Feb 5, 2024
227fe49
Adding doc to in_jsons
Feb 5, 2024
ea109a4
Changing output names for extended
Feb 5, 2024
6bb6afe
Adding warning for TR in seconds
Feb 5, 2024
6a15636
Suppress INFO loggings
Feb 5, 2024
dad628a
Removing logging.warning for the moment
Feb 6, 2024
627f170
Merge branch 'master' of github.com:karanphil/scilpy into b1_correction
karanphil Feb 7, 2024
2ced08f
Correct pep8
Feb 8, 2024
b5884cc
Merge branch 'master' of github.com:karanphil/scilpy into b1_correction
karanphil Feb 13, 2024
01554b4
Merge branch 'b1_correction' of github.com:karanphil/scilpy into b1_c…
karanphil Feb 13, 2024
9fe277b
Merge branch 'master' of github.com:karanphil/scilpy into b1_correction
Feb 14, 2024
d643905
Merge branch 'b1_correction' of github.com:karanphil/scilpy into b1_c…
Feb 14, 2024
bd9cfa6
Updating test structure for mti
Feb 14, 2024
d0ccd1b
Merge branch 'master' of github.com:karanphil/scilpy into b1_correction
Feb 20, 2024
2d33da1
Merge branch 'master' of github.com:karanphil/scilpy into b1_correction
Feb 20, 2024
04770cc
Add verbose to b1 header script
Feb 20, 2024
1008f29
Fix verbose
Feb 20, 2024
8cb2a5b
Fixing typo
karanphil Feb 21, 2024
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
432 changes: 235 additions & 197 deletions scilpy/reconst/mti.py

Large diffs are not rendered by default.

24 changes: 17 additions & 7 deletions scilpy/reconst/tests/test_mti.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,46 @@ def test_py_fspecial_gauss():
pass


def test_compute_contrasts_maps():
def test_process_contrast_map():
# toDO
pass


def test_compute_saturation():
def test_compute_saturation_map():
# toDO
pass


def test_compute_ihMT_maps():
def test_compute_ratio_map():
# toDO
pass


def test_compute_MT_maps_from_ihMT():
def test_threshold_map():
# toDO
pass


def test_compute_MT_maps():
def test_adjust_B1_map_intensities():
# toDO
pass


def test_threshold_maps():
def test_smooth_B1_map():
# toDO
pass


def test_apply_B1_correction():
def test_apply_B1_corr_empiric():
# toDO
pass


def test_apply_B1_corr_model_based():
# toDO
pass


def test_adjust_B1_map_header():
# toDO
pass
60 changes: 60 additions & 0 deletions scripts/scil_mti_adjust_B1_header.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Correct B1 map header problem.

"""

import argparse
import json
import logging

import nibabel as nib

from scilpy.io.utils import (add_overwrite_arg,
add_verbose_arg,
assert_inputs_exist,
assert_outputs_exist)
from scilpy.reconst.mti import (adjust_B1_map_header)


def _build_arg_parser():
p = argparse.ArgumentParser(description=__doc__,
formatter_class=argparse.RawTextHelpFormatter)
p.add_argument('in_B1_map',
help='Path to input B1 map file.')
p.add_argument('out_B1_map',
help='Path to output B1 map file.')
p.add_argument('in_B1_json',
help='Json file of the B1 map.')

add_verbose_arg(p)
add_overwrite_arg(p)

return p


def main():
parser = _build_arg_parser()
args = parser.parse_args()
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_outputs_exist(parser, args, args.out_B1_map)
assert_inputs_exist(parser, (args.in_B1_map, args.in_B1_json))

with open(args.in_B1_json) as curr_json:
b1_json = json.load(curr_json)
if 'PhilipsRescaleSlope' in b1_json.keys():
slope = b1_json['PhilipsRescaleSlope']
else:
raise ValueError('Rescale slope not in Json file.')

b1_img = nib.load(args.in_B1_map)

new_b1_img = adjust_B1_map_header(b1_img, slope)

nib.save(new_b1_img, args.out_B1_map)


if __name__ == '__main__':
main()
Loading
Loading