Skip to content
This repository has been archived by the owner on May 18, 2021. It is now read-only.

Problem using "resliceimg" #161

Open
evaalonsoortiz opened this issue Aug 17, 2020 · 9 comments · May be fixed by #162
Open

Problem using "resliceimg" #161

evaalonsoortiz opened this issue Aug 17, 2020 · 9 comments · May be fixed by #162
Assignees

Comments

@evaalonsoortiz
Copy link
Member

evaalonsoortiz commented Aug 17, 2020

The realtime_zshimming.m script uses a time series of B0 maps to compute the static and dynamic shim gradients that are needed for z-shimming. If z-shimming is going to be done with a gradient echo scan, then realtime_zshimming.m requires a sample magnitude gradient echo scan so that the static and dynamic shim gradient images can be resampled to the resolution of the gradient echo scan.

"realtime_zshim.m" calls resliceimg here:
https://github.com/shimming-toolbox/shimming-toolbox/blob/9081cdac6701d7df74c5db109c205655be10d54e/example/realtime_zshim.m#L310

Instead of doing realtime z-shimming with a gradient echo scan, I am attempting to do it with an EPI scan. This means that realtime_zshimming.m will use an EPI scan to resample the static and dynamic shim gradient maps to the resolution of EPI scan. When trying this, I run into the following error:

Index exceeds the number of array elements (68992).

Error in MaRdI/resliceimg (line 1342)
            [~,iNearest(iR)] = min( sqrt( ( X_Ip - X_Ep( iEp(iR) ) ).^2 + ...

Error in realtime_zshim (line 310)
GzField.resliceimg( X,Y,Z, mask ) ; % reslice static b0 image

There is sample data to test this out here. The realtime_zshim.m script can be called using realtime_zshim('phantom') in the folder containing the sample data. You will then be prompted to enter the paths of the B0 maps and the EPI (or GRE) images.

@jcohenadad
Copy link
Member

jcohenadad commented Aug 19, 2020

@jcohenadad
Copy link
Member

trying to reproduce this issue, running into another error:

Version of shimming-toolbox: 9081cda
Version of testing-data: a7e82fb0dba6e05aa5b6050ad9432ddab9cb9e38

>> realtime_zshim('phantom')
~~~~~~~~~~ realtime_zshim ~~~~~~~~~~
Current date and time: 18-Aug-2020 22:11:27
Currently analyzing: realtime_zshimming_data
(ADD SLASH AT THE END!) Field map mag path: "15_gre_field_mapping_PMUlog_2/"
Field map phase path: "16_gre_field_mapping_PMUlog_2/"
MGRE mag path: "17_gre_realtime_zshim_UNSHIMMED_2/"
Error using dir
Name must be a string scalar or character vector.

Error in MaRdI.findimages (line 2357)
ListSubdirs  = dir( [ imgDir 'echo*'] );

Error in MaRdI (line 108)
        imgList = MaRdI.findimages( imgDir ) ;

Error in realtime_zshim (line 106)
Mag = MaRdI(MGRE_mag_path);

@jcohenadad
Copy link
Member

jcohenadad commented Aug 19, 2020

@evaalonsoortiz could you please provide more information so i can reproduce this issue?
notably: what data and code versions, what exact syntax you typed, etc.

@evaalonsoortiz
Copy link
Member Author

@evaalonsoortiz
Copy link
Member Author

@evaalonsoortiz could you please provide more information so i can reproduce this issue?
notably: what data and code versions, what exact syntax you typed, etc.

The paths need to be entered with single quotations around them: '15_gre_field_mapping_PMUlog_2/'

I am using the latest commit to master. Can you tell me how you obtain the version number, like you shared above?

@jcohenadad
Copy link
Member

jcohenadad commented Aug 19, 2020

I am using the latest commit to master. Can you tell me how you obtain the version number, like you shared above?

cd into the git repository and type:

git log

or a more fancy look at the history:

git log --pretty=oneline --decorate --all --graph

I made these useful aliases in my bash_profile:

alias gs="git status -s"
alias gc="git commit -S -a"
alias gp="git push"
alias gl="git log --pretty=oneline"
alias glg="git log --pretty=oneline --decorate --all --graph"
alias gd="git diff"
alias gb="git branch"

@jcohenadad
Copy link
Member

after using the single quotes as suggested in shimming-toolbox/shimming-toolbox#161 (comment), i ran into the following issue (still a different error message than the one reported in shimming-toolbox/shimming-toolbox#161 (comment)):

Full output
>> realtime_zshim('phantom')
~~~~~~~~~~ realtime_zshim ~~~~~~~~~~
Current date and time: 18-Aug-2020 23:19:19
Currently analyzing: realtime_zshimming_data
(ADD SLASH AT THE END!) Field map mag path: '15_gre_field_mapping_PMUlog_2/'
Field map phase path: '16_gre_field_mapping_PMUlog_2/'
MGRE mag path: '17_gre_realtime_zshim_UNSHIMMED_2/'
Warning: parse_mrprot WARNING: unknown data type for DecouplingMatrixValid (value = 0x1),
discarding this line!! 
> In parse_mrprot (line 164)
  In parse_siemens_shadow (line 75)
  In dicominfosiemens (line 31)
  In MaRdI (line 116)
  In realtime_zshim (line 106) 
Warning: parse_mrprot WARNING: unknown data type for ZZMatrixVectorUUID (value =
""ac184512b29b27772d0b374eb25f258a040ffd23""), discarding this line!! 
> In parse_mrprot (line 164)
  In parse_siemens_shadow (line 75)
  In dicominfosiemens (line 31)
  In MaRdI (line 116)
  In realtime_zshim (line 106) 
Warning: parse_mrprot WARNING: unknown data type for ScatterMatrixValid (value = 0x1), discarding
this line!! 
> In parse_mrprot (line 164)
  In parse_siemens_shadow (line 75)
  In dicominfosiemens (line 31)
  In MaRdI (line 116)
  In realtime_zshim (line 106) 
Warning: parse_mrprot WARNING: unknown data type for Size1 (value = 2), discarding this line!! 
> In parse_mrprot (line 164)
  In parse_siemens_shadow (line 75)
  In dicominfosiemens (line 31)
  In MaRdI (line 116)
  In realtime_zshim (line 106) 
Warning: parse_mrprot WARNING: unknown data type for Size2 (value = 2), discarding this line!! 
> In parse_mrprot (line 164)
  In parse_siemens_shadow (line 75)
  In dicominfosiemens (line 31)
  In MaRdI (line 116)
  In realtime_zshim (line 106) 
Warning: parse_mrprot WARNING: unknown data type for Size1 (value = 2), discarding this line!! 
> In parse_mrprot (line 164)
  In parse_siemens_shadow (line 75)
  In dicominfosiemens (line 31)
  In MaRdI (line 116)
  In realtime_zshim (line 106) 
Warning: parse_mrprot WARNING: unknown data type for Size2 (value = 2), discarding this line!! 
> In parse_mrprot (line 164)
  In parse_siemens_shadow (line 75)
  In dicominfosiemens (line 31)
  In MaRdI (line 116)
  In realtime_zshim (line 106) 
Warning: parse_mrprot WARNING: unknown data type for Laterality (value = 0), discarding this
line!! 
> In parse_mrprot (line 164)
  In parse_siemens_shadow (line 75)
  In dicominfosiemens (line 31)
  In MaRdI (line 116)
  In realtime_zshim (line 106) 
Enter diameter (in mm) of desired ROI: 10

DEFAULT_DATASAVEDIR =

    './gre_seg/'

Xiangrui Li's dicm2nii (feedback to [email protected])
Validating 60 files ...
Converting 1 series (SIEMENS) into 4-D .nii.gz: subject 'acdc_112p'
 gre_realtime_zshim_UNSHIMMED_2       128x68x20x3
 Please install pigz for fast compression: http://rudix.org/packages/pigz.html
Elapsed time by dicm2nii is 0.7 seconds


--
Spinal Cord Toolbox (git-cfh/add-git-origin-in-sct-run-batch_2808-dd5fc48ad70a30df475e5fb6dc57b6f33e14a538)

�[0m
Done! To view results, type:�[0m
�[92mfsleyes ./gre_seg/tmp_sct_20200818T232005/t2s.nii.gz &
�[0m

--
Spinal Cord Toolbox (git-cfh/add-git-origin-in-sct-run-batch_2808-dd5fc48ad70a30df475e5fb6dc57b6f33e14a538)

�[0m
Create temporary folder (/var/folders/s8/4qnm5q1n261ch35b5kkclsb00000gn/T/sct-20200818232008.244237-create_mask-l8svean5)...�[0m
�[0m
Orientation:�[0m
�[0m  RPI�[0m
�[0m
Dimensions:�[0m
(128, 68, 20, 1, 2.1875, 2.1875, 3.6, 1)
�[0m
Create line...�[0m
�[94mcp data_RPI.nii line.nii�[0m
�[94msct_maths -i line.nii -mul 0 -o line.nii # in /private/var/folders/s8/4qnm5q1n261ch35b5kkclsb00000gn/T/sct-20200818232008.244237-create_mask-l8svean5�[0m
�[94msct_label_utils -i line.nii -o line.nii -create-add 64,34,0,1: 64,34,1,1: 64,34,2,1: 64,34,3,1: 64,34,4,1: 64,34,5,1: 64,34,6,1: 64,34,7,1: 64,34,8,1: 64,34,9,1: 64,34,10,1: 64,34,11,1: 64,34,12,1: 64,34,13,1: 64,34,14,1: 64,34,15,1: 64,34,16,1: 64,34,17,1: 64,34,18,1: 64,34,19,1 # in /private/var/folders/s8/4qnm5q1n261ch35b5kkclsb00000gn/T/sct-20200818232008.244237-create_mask-l8svean5�[0m
�[0m
Create mask...�[0m
�[0m
Remove temporary files...�[0m
�[94mrm -rf /var/folders/s8/4qnm5q1n261ch35b5kkclsb00000gn/T/sct-20200818232008.244237-create_mask-l8svean5�[0m
�[0m
Done! To view results, type:�[0m
�[92mfsleyes /Users/julien/code/shimming-toolbox/data-testing/realtime_zshimming_data/gre_seg/tmp_sct_20200818T232005/t2s.nii.gz -cm greyscale /Users/julien/code/shimming-toolbox/data-testing/realtime_zshimming_data/gre_seg/tmp_sct_20200818T232005/t2s_centerline.nii.gz -cm red -a 50.0 &
�[0m

--
Spinal Cord Toolbox (git-cfh/add-git-origin-in-sct-run-batch_2808-dd5fc48ad70a30df475e5fb6dc57b6f33e14a538)

�[0m  OK: ./gre_seg/tmp_sct_20200818T232005/t2s_centerline.nii.gz�[0m
�[0m
Create temporary folder (/var/folders/s8/4qnm5q1n261ch35b5kkclsb00000gn/T/sct-20200818232010.297017-create_mask-gpjyk3ad)...�[0m
�[0m
Orientation:�[0m
�[0m  RPI�[0m
�[0m
Dimensions:�[0m
(128, 68, 20, 1, 2.1875, 2.1875, 3.6, 1)
�[0m
Create mask...�[0m
�[0m
Remove temporary files...�[0m
�[94mrm -rf /var/folders/s8/4qnm5q1n261ch35b5kkclsb00000gn/T/sct-20200818232010.297017-create_mask-gpjyk3ad�[0m
�[0m
Done! To view results, type:�[0m
�[92mfsleyes /Users/julien/code/shimming-toolbox/data-testing/realtime_zshimming_data/gre_seg/tmp_sct_20200818T232005/t2s.nii.gz -cm greyscale /Users/julien/code/shimming-toolbox/data-testing/realtime_zshimming_data/gre_seg/tmp_sct_20200818T232005/t2s_seg.nii.gz -cm red -a 50.0 &
�[0m

--
Spinal Cord Toolbox (git-cfh/add-git-origin-in-sct-run-batch_2808-dd5fc48ad70a30df475e5fb6dc57b6f33e14a538)

�[0m  OK: ./gre_seg/tmp_sct_20200818T232005/t2s_centerline.nii.gz�[0m
�[0m
Create temporary folder (/var/folders/s8/4qnm5q1n261ch35b5kkclsb00000gn/T/sct-20200818232010.823914-create_mask-jb9fnq78)...�[0m
�[0m
Orientation:�[0m
�[0m  RPI�[0m
�[0m
Dimensions:�[0m
(128, 68, 20, 1, 2.1875, 2.1875, 3.6, 1)
�[0m
Create mask...�[0m
�[0m
Remove temporary files...�[0m
�[94mrm -rf /var/folders/s8/4qnm5q1n261ch35b5kkclsb00000gn/T/sct-20200818232010.823914-create_mask-jb9fnq78�[0m
�[0m
Done! To view results, type:�[0m
�[92mfsleyes /Users/julien/code/shimming-toolbox/data-testing/realtime_zshimming_data/gre_seg/tmp_sct_20200818T232005/t2s.nii.gz -cm greyscale /Users/julien/code/shimming-toolbox/data-testing/realtime_zshimming_data/gre_seg/tmp_sct_20200818T232005/t2s_weights.nii.gz -cm red -a 50.0 &
�[0m
2D phase unwrapping algorithm: QGU
Loading img 1 of 2
Loading img 2 of 2
Unwrapping volume 1 of 60
Unwrapping volume 2 of 60
Unwrapping volume 3 of 60
Unwrapping volume 4 of 60
Unwrapping volume 5 of 60
Unwrapping volume 6 of 60
Unwrapping volume 7 of 60
Unwrapping volume 8 of 60
Unwrapping volume 9 of 60
Unwrapping volume 10 of 60
Unwrapping volume 11 of 60
Unwrapping volume 12 of 60
Unwrapping volume 13 of 60
Unwrapping volume 14 of 60
Unwrapping volume 15 of 60
Unwrapping volume 16 of 60
Unwrapping volume 17 of 60
Unwrapping volume 18 of 60
Unwrapping volume 19 of 60
Unwrapping volume 20 of 60
Unwrapping volume 21 of 60
Unwrapping volume 22 of 60
Unwrapping volume 23 of 60
Unwrapping volume 24 of 60
Unwrapping volume 25 of 60
Unwrapping volume 26 of 60
Unwrapping volume 27 of 60
Unwrapping volume 28 of 60
Unwrapping volume 29 of 60
Unwrapping volume 30 of 60
Unwrapping volume 31 of 60
Unwrapping volume 32 of 60
Unwrapping volume 33 of 60
Unwrapping volume 34 of 60
Unwrapping volume 35 of 60
Unwrapping volume 36 of 60
Unwrapping volume 37 of 60
Unwrapping volume 38 of 60
Unwrapping volume 39 of 60
Unwrapping volume 40 of 60
Unwrapping volume 41 of 60
Unwrapping volume 42 of 60
Unwrapping volume 43 of 60
Unwrapping volume 44 of 60
Unwrapping volume 45 of 60
Unwrapping volume 46 of 60
Unwrapping volume 47 of 60
Unwrapping volume 48 of 60
Unwrapping volume 49 of 60
Unwrapping volume 50 of 60
Unwrapping volume 51 of 60
Unwrapping volume 52 of 60
Unwrapping volume 53 of 60
Unwrapping volume 54 of 60
Unwrapping volume 55 of 60
Unwrapping volume 56 of 60
Unwrapping volume 57 of 60
Unwrapping volume 58 of 60
Unwrapping volume 59 of 60
Unwrapping volume 60 of 60
Correcting for potential temporal phase wraps...
Dot indexing is not supported for variables of this type.

Error in MaRdI/getacquisitiontime (line 774)
                t(iSlice, iEcho, iMeasurement) = convertacquisitiontime(
                Img.Hdrs{iSlice,iEcho,iMeasurement}.AcquisitionTime ) ;

Error in MaRdI/estimatekorigintime (line 611)
tAcq = Img.getacquisitiontime() ;

Error in MaRdI/associateaux (line 297)
tk0      = Img.estimatekorigintime() ;

Error in realtime_zshim (line 161)
B0Fields.associateaux( Pmu );

@evaalonsoortiz did you go that far in the processing or does your error appear afterwards?

@evaalonsoortiz
Copy link
Member Author

@jcohenadad I believe you are getting that error because we only kept 10 field mapping volumes, whereas the original acquisition had 60 (and the dicom header states that there are 60 volumes). Perhaps we should go back to the example data and keep the 60 volumes.

@rtopfer
Copy link
Contributor

rtopfer commented Aug 19, 2020

just checked, that ^ is why. the MaRdI constructor uses the number of repetitions/measurements to initialize the object, so you end up with a bunch of empty images if they're they're claimed in the header but the files are missing. Unfortunately the class design relies entirely on the validity of the header so idk how easy it would be to fix. Can at least add a check + error message.

@rtopfer rtopfer linked a pull request Aug 19, 2020 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants