kschan0214 / sepia

Matlab GUI pipeline application for quantitative susceptibility mapping (QSM)
MIT License
46 stars 10 forks source link

Using sepia with single echo data #15

Closed JoNumc closed 1 year ago

JoNumc commented 3 years ago

Hi Kwok,

I'm trying to process a subject using Sepia with single echo 7T data. However, when trying to run sepia it errors out with the folloing error message:

Index exceeds the number of array elements (3).

Error in SepiaIOWrapper>check_input_dimension (line 472)
if matrixSize_magn(4) ~= length(TE)

Error in SepiaIOWrapper (line 185)
check_input_dimension(magn,fieldMap,matrixSize,TE);

Error in sepiaIO (line 78)
    SepiaIOWrapper(input,output,maskFullName,algorParam);

Error in sepia_config (line 32)
sepiaIO(input,output_basename,mask_filename,algorParam);

Error in run (line 91)
evalin('caller', strcat(script, ';'));

Error in sepia>PushbuttonStart_Callback (line 471)
    run(configFilename);

Error while evaluating UIControl Callback.

Is this an issue due to the fact that i'm using single echo data? Or am I missing something very obvious? See below for the log, error and config file.

Looking forward to hearing from you!

Best, Jasper

Config:

% This file is generated by SEPIA version: v0.8.1
% add general Path
sepia_addpath

% Input/Output filenames
input = '/Users/jnuninga/Documents/MATLAB/Subject_1' ;
output_basename = '/Users/jnuninga/Documents/MATLAB/Subject_1/output/Sepia' ;
mask_filename = [''] ;

% General algorithm parameters
algorParam=struct();
algorParam.general.isBET       = 0 ;
algorParam.general.isInvert    = 0 ;
% Total field recovery algorithm parameters
algorParam.unwrap.echoCombMethod = 'Optimum weights' ;
algorParam.unwrap.unwrapMethod   = 'Laplacian (MEDI)' ;
algorParam.unwrap.isEddyCorrect  = 0 ;
algorParam.unwrap.isSaveUnwrappedEcho = 0 ;
% Background field removal algorithm parameters
algorParam.bfr.refine_method = '3D Polynomial' ;
algorParam.bfr.refine_order = 4 ;
algorParam.bfr.erode_radius = 0 ;
algorParam.bfr.method = 'LBV' ;
algorParam.bfr.tol = 0.0001 ;
algorParam.bfr.depth = 5 ;
algorParam.bfr.peel = 2 ;
% QSM algorithm parameters
algorParam.qsm.reference_tissue = 'None' ;
algorParam.qsm.method = 'TKD' ;
algorParam.qsm.threshold = 0.15 ;

sepiaIO(input,output_basename,mask_filename,algorParam);

Log:

SEPIA configuration file already exists in the output directory.
Running script: /Users/jnuninga/Documents/MATLAB/Subject_1/output/sepia_config.m
Running one-stop processing pipeline...
Output directory       : /Users/jnuninga/Documents/MATLAB/Subject_1/output/
Output filename prefix : Sepia_
---------
Load data
---------
Searching input directory...
One 'ph' file is found: /Users/jnuninga/Documents/MATLAB/Subject_1/S1_phase.nii
One 'mag' file is found: /Users/jnuninga/Documents/MATLAB/Subject_1/S1_magn.nii
No file with name containing string 'weights' is detected.
One 'header' file is found: /Users/jnuninga/Documents/MATLAB/Subject_1/sepia_header.mat
Phase data is loaded.
Magnitude data is loaded.
No weighting map is loaded. Default QSM weighting method will be used for QSM.
Header data is loaded.
Validating SEPIA header...
Input SEPIA header is valid.
Validating input NIfTI files...
There was an error! Please check the command window/error message file for more information.

Error:

The identifier was:
MATLAB:badsubscript

The message was:

Index exceeds the number of array elements (3).

Error in SepiaIOWrapper>check_input_dimension (line 472)
if matrixSize_magn(4) ~= length(TE)

Error in SepiaIOWrapper (line 185)
check_input_dimension(magn,fieldMap,matrixSize,TE);

Error in sepiaIO (line 78)
    SepiaIOWrapper(input,output,maskFullName,algorParam);

Error in sepia_config (line 32)
sepiaIO(input,output_basename,mask_filename,algorParam);

Error in run (line 91)
evalin('caller', strcat(script, ';'));

Error in sepia>PushbuttonStart_Callback (line 471)
    run(configFilename);
kschan0214 commented 3 years ago

Hi Jasper,

Thanks for the reporting. This is a bug introduced in v.0.8.1 when upgrading from v0.8.0: newly added input validation step in SEPIA checks the consistency of the input data with the header information. For single-echo dataset, there is not 4-th dimension matrix size of the input images in which the software was trying to retrieve (i.e. matrixSize_magn(4) does not exist), causing the error you encountered.

I made an update to fix the bug in the current master branch. Can you update your SEPIA to the current master and see if this can solve the problem? The latest version should be shown as v0.8.1.1 (commit 52dd20b):

Screenshot 2021-05-06 at 16 06 32

P.S. Both 'Optimum weights' and 'MEDI nonlinear fit' should work on single-echo data.

Best,

Kwok

kschan0214 commented 3 years ago

Hi Jasper,

Just want to have a quick follow-up to see if you have the chance to test on my suggestion. If so, I'd be grateful to know whether it works or not. :)

kschan0214 commented 1 year ago

I'll closed this issue. Please start a new issue if there is any update.