From 1531a49ce90bd408e99b6790e86b19f8d85dcdf4 Mon Sep 17 00:00:00 2001 From: jamienear Date: Wed, 11 Nov 2015 13:17:01 -0500 Subject: [PATCH] Added new function for aligining the edit-on/off subspectra of mega-press data prior to subtraction. This function is similar to op_alignMPSubspecs.m, except that it uses only a limited frequency range to perform the alignment. --- processingTools/op_alignMPSubspecs_fd.m | 136 ++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 processingTools/op_alignMPSubspecs_fd.m diff --git a/processingTools/op_alignMPSubspecs_fd.m b/processingTools/op_alignMPSubspecs_fd.m new file mode 100644 index 0000000..cd933c0 --- /dev/null +++ b/processingTools/op_alignMPSubspecs_fd.m @@ -0,0 +1,136 @@ +% op_alignMPSubspecs_fd.m +% Jamie Near, McGill University 2014. +% +% USAGE: +% [out,fs,phs]=op_alignMPSubspecs_fd(in,initPars); +% +% DESCRIPTION: +% Apply spectral registration to align MEGA-PRESS subspectra prior to +% subtraction. This function is designed to minimize subtraction artefacts +% from choline, and residual water. This is intended to be used after averaging. +% +% INPUTS: +% in = Input data structure. +% initPars = (Optional) Initial fit parameters [freq(Hz), phase(degrees)]. Default=[0,0]; + +function [out,fs,phs]=op_alignMPSubspecs_fd(in,initPars) + +if ~in.flags.addedrcvrs + error('ERROR: I think it only makes sense to do this after you have combined the channels using op_addrcvrs. ABORTING!!'); +end + +if in.dims.subSpecs==0 + error('ERROR: Must have multiple subspectra. ABORTING!!'); +end + +if in.dims.averages + error('ERROR: Signal averaging must be performed before this step. ABORTING!!'); +end + +if nargin<3 + parsGuess=[0,0]; +else + parsGuess=initPars; +end + +fs=0; +phs=0; +fids=zeros(in.sz(in.dims.t),1); + + +disp('aligning the MEGA-PRESS edit-ON sub-spectrum to the edit-OFF sub-spectrum'); + +%NOTE: Alignment is not performed in the regions of the spectrum where +%the difference spectrum is large (ie. near NAA, 3ppm GABA, or 3.7ppm +%Glx). +minfrq1=2.46; +maxfrq1=2.9; +minfrq2=3.1; +maxfrq2=3.6; +minfrq3=3.85; +maxfrq3=4.1; +minfrq4=4.6; +maxfrq4=5.2; + +%freqWindow1=in.ppm>minfrq1 & in.ppmminfrq2 & in.ppmminfrq3 & in.ppmminfrq4 & in.ppmminfrq3 & ppm