Tissue Segmentation and Issue Running Osprey Process Data

Hello,

I’m working with Megapress and CSI data. I’ve used Gannet for processing Megapress previously and am now looking into Osprey for the tissue segmentation for each of the metabolites. Running CoRegister and Segment in Osprey generates an output of the tissue segmentation for the subject, does Osprey provide GM, WM, and CSF content of each of the voxels?

Additionally, when trying to run Process data within Osprey, I’m getting the following error message:
MEGA ON/OFF classifier does not recognize the input argument ‘target’. We automatically assume no reordering. You can change that in osp_onOFFClassifyMEGA.m
Unrecognized function or variable ‘inA’.

Error in osp_onOffClassifyMEGA (line 69)
** outA = inA;**

Error in OspreyProcess (line 405)
** [raw, switchOrder] = osp_onOffClassifyMEGA(raw, target,Order);**

Error in osp_onProc (line 37)
** MRSCont = OspreyProcess(MRSCont);**

Error while evaluating UIControl Callback.

I am using Megapress data (.dat files). Please see the lines from my job file below:

%%% 1. SPECIFY SEQUENCE INFORMATION %%%*

% Specify sequence type
seqType = ‘MEGA’; % OPTIONS: - ‘unedited’ (default)
** % - ‘MEGA’**
** % - ‘HERMES’**
** % - ‘HERCULES’**

% Specify editing targets
editTarget = {‘unedited’}; % OPTIONS: - {‘none’} (default if ‘unedited’)
** % - {‘GABA’}, {‘GSH’}, {‘Lac’}, {‘PE322’}, {‘PE398’} (for ‘MEGA’)**
** % - {‘GABA’, ‘GSH’}, {‘GABA’, ‘Lac’}, {‘NAA’, ‘NAAG’} (for 'HERMES’and ‘HERCULES’)**

** % Specify data scenario**
dataScenario = ‘MRSI’; % OPTIONS: - ‘invivo’ (default)
** % - ‘phantom’ **
** % - ‘PRIAM’ **
** % - ‘MRSI’ **
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Can you please assist?

Thank you so much!
Rhi

Hi Rhi,

Running CoRegister and Segment in Osprey generates an output of the tissue segmentation for the subject, does Osprey provide GM, WM, and CSF content of each of the voxels?

Yes it does. Osprey is very similar to Gannet in that respect, using SPM-12 for segmentation. If you’ve successfully run OspreyCoreg and OspreySegment, then the segmented tissue maps will be in the output folder (wherever you chose in the job file), along with .tsv tables summarizing the tissue fractions. Additionally, this information will be stored in the Matlab data (MRSCont.seg etc.).

Additionally, when trying to run Process data within Osprey, I’m getting the following error message

You’ll need to specify the edit target for your protocol in the job file. Assuming you’re doing GABA-edited MEGA-PRESS, you can amend your job file as follows:

editTarget = {‘GABA’}; % OPTIONS: - {‘unedited’} (default if ‘unedited’)
** % - {‘GABA’}, {‘GSH’}, {‘Lac’}, {‘PE322’}, {‘PE398’} (for ‘MEGA’)**
** % - {‘GABA’, ‘GSH’}, {‘GABA’, ‘Lac’}, {‘NAA’, ‘NAAG’} (for 'HERMES’and ‘HERCULES’)**

Finally, was this edited MRSI data? If so, I’m not sure this will work, but if not, you’ll need to amend the dataScenario line of your jobfile, too:

dataScenario = 'in-vivo’;

Hope that helps,
Chris

Hi Chris,

Thank you, I see the segmented tissue maps now!

However, I am running into another error; I was able to coregister and segment half of my dataset without any issues, but for the remaining subjects am getting the following error:
Error using OspreyJob (line 650)
Invalid job file! A job file needs to contain at least metabolite data in the field ‘files’.

Error in Osprey/loadJob (line 98)
** gui.data.MRSCont = OspreyJob(gui.out{1},1);**

Error in Osprey/onLoadJob (line 166)
** loadJob(gui);**

Error while evaluating UIControl Callback.

I have not changed anything else in my job file, except for specifying the file path with the subject IDs. Would you be able to assist please?

Thank you!
Rhi

Hi Rhi,

Glad that worked for you!

Invalid job file! A job file needs to contain at least metabolite data in the field ‘files’.

This error suggests that you don’t have any “files” defined after Osprey runs your job file. As a quick check, try running your jobfile directly via Matlab, and then ensure that “files” exists in your workspace, and that the entries correspond to your data.

If that’s not the issue, I’m happy to take a look at the jobfile for you.

Cheers,
Chris

Thank you so much for the quick response! I’m actually able to load the data now, I had to specify my path in both lines 226-261, and 273-304. I’ve only run the ‘CoRegister’ and ‘Segment’ parts of Osprey in order to obtain the segmented tissue maps. I’m getting a different error for ‘Process data’ after amending my job file as you suggested above; error below:
Index exceeds the number of array elements (1).

Error in OspreyProcess (line 252)
** raw.specReg{1}.weights{2} = raw.specReg{1}.weights{2}'/(max(raw.specReg{1}.weights{2}(1,:)));**

Error in osp_onProc (line 37)
** MRSCont = OspreyProcess(MRSCont);**


Error while evaluating UIControl Callback.

Attaching my job file here, thank you!
jobfile.docx (21.3 KB)

Hi Rhi,

A few things:

  1. You shouldn’t need to amend the jobfile after generating the segmentation. The jobfile options for parsing external segmentation results are intended for those who want to do their segmentation in a different program prior to using Osprey. Ideally, jobfiles shouldn’t need amending during analysis. They’re supposed to serve as a record of what you ran, and a way to reproduce your analysis afterwards.
  2. Are you trying to analyze a single dataset, or multiple? If it’s just a single dataset, as your jobfile seems to indicate, then you don’t need to use the loop structure from the example. You can do something like this: Rhi_SingleJobFile.m.zip (4.4 KB). If you are analyzing multiple spectra, then the loop would need to be set up differently depending on how your data is organized.
  3. Regarding your error, it seems to be related to the dimensions of your data. Which sequence did you use to acquire the data? Was it the Siemens WIP? If you’re able to share the data with me somehow, I’m happy to try and identify the issue.

Cheers,
Chris

1 Like

Hi Chris,

Noted, thank you for the explanation - that’s helpful to know! Moving forward, I will use the single job file.

Initially, we just wanted to segment the tissue maps therefore was not running the ‘Process data’ through Osprey. Yes, I believe it is Siemens WIP. Thank you so much for offering to take a look, data is attached here Siemens MRS Data - Google Drive
(please note I only ran the .dat files but have .rda files as well that I’ve included here).

Thank you so much!
Rhi

Hi Rhi,

Thanks for sending that. I tested your data with the jobfile I sent and (after fixing a typo I made… Here’s the updated version: Rhi_SingleJobFile.m.zip (4.5 KB)) Osprey successfully processed and fit your data. I suspect the issue you’re having is related to your original Osprey data structure causing a mis-match in the expected dimensions. Try running a fresh analysis from the beginning using the attached job file. Hopefully that will resolve your issue!

Cheers,
Chris

Hi Chris,

Thanks so much for testing that for me and editing my job file, I’m able to successfully process the megapress data now!

Sorry, but one last question - does Osprey process MRSI data and compute fractions of %GM, %WM, and %CSF? I tried with the .rda single files I have and got the following:

Unable to perform assignment because the size of the left side is 1-by-1024 and the size of the right side is 1-by-1024-by-16-by-16.

Error in io_loadspec_rda (line 182)
** fids(kk,:slight_smile: = complex(hmm(1,:,:,:,:),hmm(2,:,:,:,:));**

Error in osp_LoadRDA (line 66)
** raw = io_loadspec_rda(MRSCont.files{metab_ll,kk});**

Error in OspreyLoad (line 183)
** [MRSCont] = osp_LoadRDA(MRSCont);**

Error in osp_onLoad (line 35)
** MRSCont = OspreyLoad(MRSCont);**

Error while evaluating UIControl Callback.

Thanks so much!
Rhi

I’m not sure we have worked out how to correctly read out MRSI data from RDA files, to be honest. We could probably make it work, but this is likely not going to be an easy quick fix.

1 Like

Noted, thank you!

Appreciate all the help!