Skip to content

Commit feac890

Browse files
committed
insert some more logging to console;
change naming of lr reg
1 parent 1c3ec8b commit feac890

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

pymritools/config/emc/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class FitSettings(BaseClass):
115115
alias="-iimg", default=False,
116116
help="if False, toggle FFT to get input to image space first for k-space input."
117117
)
118-
use_low_rank_regularisation: bool = field(
118+
low_rank_regularisation: bool = field(
119119
alias="-lr", default=True,
120120
help="For noisy channel wise matching, we can regularise the matching by using low-rank approximations in small neighborhoods in the fitting."
121121
)

pymritools/modeling/dictionary/grid_search_channels.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,10 @@ def wrap_cli(settings: EmcFitSettings):
562562

563563
logger.info(f"load database")
564564
db = DB.load(settings.input_database)
565+
vals = db.get_t1_t2_b1_b0_values()
566+
logger.info(f"\t\t- Value range:")
567+
for i in range(4):
568+
logger.info(f"\t\t\t {['T1', 'T2', 'B1', 'B0'][i]}: {(vals[i].min().item(), vals[i].max().item())}")
565569

566570
path = plib.Path(settings.out_path)
567571

@@ -573,6 +577,7 @@ def wrap_cli(settings: EmcFitSettings):
573577

574578
# fft reconned k-space
575579
if not settings.input_in_image_space:
580+
logger.info(f"FFT data into image space")
576581
data = fft_to_img(data, dims=(0, 1))
577582

578583
# set database
@@ -591,6 +596,7 @@ def wrap_cli(settings: EmcFitSettings):
591596
while b1_map.ndim < data.ndim - 2:
592597
b1_map = b1_map.unsqueeze(-1)
593598
b1_data = b1_map.expand_as(data[..., 0, 0])
599+
logger.info(f"\t\t- B1 Input value range: {(b1_data[b1_data>1e-6].min().item(), b1_data.max().item())}")
594600

595601
path_in_b0 = plib.Path(settings.input_b0)
596602
if not path_in_b0.is_file():
@@ -603,16 +609,17 @@ def wrap_cli(settings: EmcFitSettings):
603609
while b0_map.ndim < data.ndim - 2:
604610
b0_map = b0_map.unsqueeze(-1)
605611
b0_data = b0_map.expand_as(data[..., 0, 0])
612+
logger.info(f"\t\t- B0 Input value range: {(b0_data.min().item(), b0_data.max().item())}")
606613

607614
if settings.rsos_channel_combine:
608-
b1_data = root_sum_of_squares(b1_data, dim_channel=-1).unsqueeze(-1) if b1_data is not None else None
615+
# b1_data = root_sum_of_squares(b1_data, dim_channel=-1).unsqueeze(-1) if b1_data is not None else None
609616
data = root_sum_of_squares(input_data=data, dim_channel=-2).unsqueeze(-2)
610617

611618
fit_mese(
612619
data_xyzce=data, db_t1t2b1b0=db_pattern,
613620
t1_vals=t1_vals, t2_vals=t2_vals, b1_vals=b1_vals, b0_vals=b0_vals,
614621
path_out=path, b1_data=b1_data, b0_data=b0_data, device=device, input_affine=affine,
615-
lr_reg=settings.use_low_rank_regularisation
622+
lr_reg=settings.low_rank_regularisation
616623
)
617624

618625

@@ -1028,10 +1035,13 @@ def fit_mese(
10281035
d, img_aff=input_affine, path_to_dir=path_out,
10291036
file_name=["b1_estimate_smoothed", "b1_estimate", "b0_estimate_smoothed", "b0_estimate"][i]
10301037
)
1031-
if data_xyzce.shape[-2] > 1:
1038+
if data_xyzce.ndim - 1 > b1_data.ndim:
10321039
# need to expand back to channels
10331040
b1_data = b1_data.unsqueeze(-1).expand_as(data_xyzce[..., 0])
1034-
b0_data = b0_data.unsqueeze(-1).expand_as(data_xyzce[..., 0]) / np.pi
1041+
1042+
if data_xyzce.ndim - 1 > b0_data.ndim:
1043+
# need to expand back to channels
1044+
b0_data = b0_data.unsqueeze(-1).expand_as(data_xyzce[..., 0])
10351045

10361046
# now use this for input to to the regularised fit
10371047
t2, l2_res = regularised_fit(

0 commit comments

Comments
 (0)