ok, thanks, now make sense On the other hand, residuals are: res = data - pred right? 2016-09-29 14:00 GMT+02:00 Saad Jbabdi <[log in to unmask]>: > Hi - I know what ‘they’ are doing as I wrote that bit of code :) > > I just tried and I get identical results (except for a few voxels at the > edge of the brain like I said). Here are the steps I suggested: > > In a terminal: > dtigen -t dti_tensor.nii.gz --s0=dti_S0 -o dti_pred -r bvecs -b bvals -m > nodif_brain_mask > > In matlab > sse=read_avw('dti_sse'); > pred=read_avw('dti_pred'); > data=read_avw('data'); > mask=read_avw('nodif_brain_mask'); > mask=~~mask; > > data=reshape(data,numel(mask),size(data,4)); > pred=reshape(pred,numel(mask),size(pred,4)); > > data=data(mask,:); > pred=pred(mask,:); > > x=sum((log(data)-log(pred)).^2,2); > > > figure,plot(x,sse(mask),'o') > > > You should see that most voxels give identical results. > > Cheers > Saad > > > > > > > > > On 29 Sep 2016, at 11:59, Ana Maria Escorza <[log in to unmask] > <[log in to unmask]>> wrote: > > It remains different from that obtained with dtifit. The values are higher > with that formula > Maybe they do something like this: > > http://stats.stackexchange.com/questions/16845/log-squared-error-accuracy- > justification-data-mining-competition > > What do you think? > > 2016-09-29 12:52 GMT+02:00 Saad Jbabdi <[log in to unmask]>: > >> It’s good enough for most uses. Also you probably only have negative >> values at the edge of the brain probably caused by spline interpolation >> during resampling. >> >> Cheers >> Saad >> >> >> >> >> On 29 Sep 2016, at 11:50, Ana Maria Escorza <[log in to unmask] >> <[log in to unmask]>> wrote: >> >> but is it correct ignore values negatives in order to obtain sse? >> >> 2016-09-29 12:47 GMT+02:00 Saad Jbabdi <[log in to unmask]>: >> >>> data(data<0)=0 >>> >>> >>> >>> >>> >>> On 29 Sep 2016, at 11:41, Ana Maria Escorza <[log in to unmask] >>> <[log in to unmask]>> wrote: >>> >>> Thanks, that is for 0 values. >>> >>> But my sse has complex values after that. And it is different from sse >>> obtain from dtifii >>> >>> >>> Cheers, >>> Ana. >>> >>> 2016-09-29 12:35 GMT+02:00 Saad Jbabdi <[log in to unmask]>: >>> >>>> An easy way to do this in matlab: >>>> >>>> SSE = sum ( (log(data+~data) - log(pred+~pred)).^2, 4 ) >>>> >>>> The trick of doing x+~x means when x=0, then x+~x=1 and the log is >>>> zero, so doesn’t count in the sum. >>>> >>>> Cheers >>>> Saad >>>> >>>> >>>> >>>> >>>> >>>> >>>> On 29 Sep 2016, at 11:08, Ana Maria Escorza < >>>> [log in to unmask] <[log in to unmask]>> wrote: >>>> >>>> You mean do not do the logarithm of negative values? >>>> >>>> Remove negative values and put in after do the log? >>>> >>>> 2016-09-29 12:02 GMT+02:00 Saad Jbabdi <[log in to unmask]>: >>>> >>>>> In matlab, log is ln >>>>> >>>>> Just remove negative values before you calculate the sse >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> On 29 Sep 2016, at 10:49, Ana Maria Escorza < >>>>> [log in to unmask] <[log in to unmask]>> wrote: >>>>> >>>>> Hi, >>>>> >>>>> with log you mean log10 or ln? >>>>> >>>>> what you mean with safeguards? >>>>> >>>>> I do that I obtain complex numbers in sse. >>>>> >>>>> Cheers >>>>> >>>>> 2016-09-29 10:51 GMT+02:00 Saad Jbabdi <[log in to unmask]>: >>>>> >>>>>> Hi - I believe DTIFIT outputs the sum squared error in log-space, >>>>>> i.e. sum( { log(data) - log(prediction) }^2 ) >>>>>> >>>>>> There are also a couple of safeguards inside DTIFIT to make sure it >>>>>> can take the log. >>>>>> >>>>>> Cheers >>>>>> Saad >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> On 29 Sep 2016, at 08:21, Ana Maria Escorza < >>>>>> [log in to unmask] <[log in to unmask]>> wrote: >>>>>> >>>>>> Once I have got the original DWIs and 'DWIs from DTs' exported >>>>>> (with dtigen) and load into matlab, I try to calculate the sse of tensor >>>>>> estimation that is calculated by sum((orDWI-DWI_DT).^2,4) >>>>>> >>>>>> But I didn't obtain the same that with --sse in dtifit, why? >>>>>> >>>>>> 2016-09-28 18:22 GMT+02:00 Ana Maria Escorza < >>>>>> [log in to unmask]>: >>>>>> >>>>>>> How Can I subtract? with fslmaths from both .nii? >>>>>>> >>>>>>> 2016-09-28 18:18 GMT+02:00 Saad Jbabdi <[log in to unmask]>: >>>>>>> >>>>>>>> Hi - you can use ‘dtigen’ to generate predictions given the DTI >>>>>>>> tensor (which you can save in DTIFIT with —save_tensor) and then substract >>>>>>>> that prediction from the data. >>>>>>>> >>>>>>>> Cheers >>>>>>>> Saad >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> On 28 Sep 2016, at 14:42, Ana E. <[log in to unmask] >>>>>>>> <[log in to unmask]>> wrote: >>>>>>>> >>>>>>>> Hello, >>>>>>>> >>>>>>>> I am looking for a function to obtain the residual DWI from the >>>>>>>> diffusion tensor. >>>>>>>> >>>>>>>> I see that I can use --sse in dtifit, but this is for 3D volume. I >>>>>>>> would like 4D. >>>>>>>> >>>>>>>> Thanks >>>>>>>> >>>>>>>> Ana. >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>> >>>> >>> >>> >> >> > >