A few modification suggestions for the code

Hey, I ran into some problems when using the Osprey software for the first time. I did some measurements on a phantom with our staff scientist (Scanner: Siemens Skyra 3T) and didn’t move the voxel at all, so that all of the measurements were done at the isocenter. This created an error message were it said that the ‘sPosition’ parameter was not found. To fix this we added:

% Checks if the sPosition field has been created, if not creates one.

if ~isfield(dcmHeader.sSpecPara.sVoI, ‘sPosition’)

dcmHeader.sSpecPara.sVoI.sPosition.dCor = realmin(‘double’);

end

in Load/dicom_load_tools/read_dcm_header.m (around line: 160)

Another error happened when loading the files to osprey. I don’t know if this is a problem only for my operating system, but when it started to read the DICOM datafiles (which have a random length) Osprey used the longest of them as the length and added whitespace to the end of the other filenames. Which led to an error message of “file not found”. To solve this issue we edited:

% Set flags

if ~isempty(MRSCont.files)

MRSCont.flags.hasFiles = 1;

% Take away extra whitespace at the end of the filename

files = MRSCont.files;

for kk = 1:length(files)

files{kk} = strtrim(files{kk});

end

MRSCont.files = files; clear files;

% end of added code

end

In Load/OspreyLoad.m (around line: 30)

The last error we noticed was that Osprey would not accept only one single measurement as a dataset. We ran into this problem when we just wanted to see what one measurement of the phantom data would look like. I don’t know if this is relevant, because usually you use a lot of measurements to get the average, but with this modification to the code we got it to work:

%filesInFolder = fullfile(folder, {filesInFolder.name}); Original version

filesInFolder = fullfile({filesInFolder.folder}, {filesInFolder.name});

In Libraries/FID-A/inputOutput/io_loadspec_dicom.m (around line: 29)

Hope this helps anyone who runs into the same issues!
-Nella

Hi @zellavie,

Thanks for the suggestions!

  1. I’ll add the changes for the DICOM reader to the develop branch.
  2. How did you create the jobfile for this analysis. Did you sue the GUI or did you create it yourself? And is it a .m or a .json file. I’ll also add a similar fix to the develop branch.
  3. Not sure I totally understand the issue here. You did manually delete all the files but one from the folder and tried to run the analysis? I think the easier way would be to load the DICOM file as usually and then modify the MRSCont.raw entry to only contain one average and change the matching parameters in there.

Best,
Helge

Hi @Helge, @zellavie,

FWIW, I just ran into the exact same issue as (2); created a simple batch file through the GUI, Matlab 2019b on Linux, the filenames coming back from the file chooser are padded with spaces up to the length of the longest filename. Here’s how it appeared in the generated .json file:

 25     "files": ["...619#Head_svs_edit_mgs_univ_GSH_lesj.dat",
 26               "....722#Head_svs_se_30_friskt_vev.dat     ",
 27               "....140#Head_svs_se_30_lesjon.dat         "],

Thanks @zellavie for identifying this issue, and for the quick fix!

Looking more closely, this issue could affect all the file lists (not just MRSCont.files). It arises because spm_select (called in MRSDataButtonPushed callback, and a few other places in CreateOspreyJob_app.m) returns a character array, which is by definition square (so, shorter strings are padded). If you pass the result through cellstr (as already done in OspreySeg.m), it’ll remove the trailing whitespace for you. One catch is that this breaks the isempty check, so the cellstr conversion should happen after that.

I’ll submit a patch to CreateOspreyJob_app.m, to fix the problem at its source. It affects all spm_select calls returning more than one item, ie MRSDataButtonPushed, H2OReferenceButtonPushed, H2OShortTEButtonPushed, MetaboliteNulledButtonPushed, T1DataniftiniiButtonPushed)

Alex.

Hi @alex,

Thanks so much for the GitHub submission. I’ll merge it right away.

Helge