spisakt / pTFCE

Probabilistic Threshold-Free Cluster Enhancement of Neuroimages
https://spisakt.github.io/pTFCE/
BSD 3-Clause "New" or "Revised" License
38 stars 6 forks source link

What is the thresholded map? #4

Closed dorianps closed 5 years ago

dorianps commented 5 years ago

Hi @spisakt

I testing pTFCE on some simulated data of the LESYMAP package. I am a bit unsure what to do with the output. Looks like the $Z output is an unthresholded map, I though I need to use $fwer0.05.Z to threshold $Z. This is not producing good results. I noticed that the zscores in $Z are all higher than the input map. I tried applying $fwer0.05.Z to threshold my original z-map, and that seems to work a bit better. Wanted to double check with you what is the right way to do this. The area of simulation in LESYMAP is the inferior temporal cortex.

Here is more or less the code I used for tests.

library(LESYMAP)

lesydata = file.path(find.package('LESYMAP'),'extdata')
filenames = Sys.glob(file.path(lesydata, 'lesions', 'Subject*.nii.gz'))
behavior = Sys.glob(file.path(lesydata, 'behavior', 'behavior.txt'))
template = antsImageRead(
  Sys.glob(file.path(lesydata, 'template', 'ch2.nii.gz')))
lsm = lesymap(filenames, behavior, method = 'ttest',
              multipleComparison = 'none', checkAssumptions=F)

save.lesymap(lsm, '~/pTFCEtest')
templatefile = Sys.glob(file.path(lesydata, 'template', 'ch2.nii.gz'))

file.copy(templatefile, '~/pTFCEtest/ch2.nii.gz')

# plot(template, lsm$stat.img, window.overlay = range(lsm$stat.img))
#
# plot(template, lsm$zmap.img, window.overlay = range(lsm$zmap.img))

zfilename = paste0(tempfile('zmap'), '.nii')
maskfilename = paste0(tempfile('mask'), '.nii')

antsImageWrite(lsm$zmap.img, zfilename)
antsImageWrite(lsm$mask.img, maskfilename)

library(pTFCE)
library(oro.nifti)

Z=readNIfTI(zfilename);

MASK=readNIfTI(maskfilename);

pTFCE=ptfce(Z, MASK);

pTFCE$number_of_resels
pTFCE$fwer0.05.Z
pTFCE$Z

writeNIfTI(pTFCE$Z, '~/pTFCEtest/pTFCE_Z.nii')

newZ = pTFCE$Z
newZ[newZ < pTFCE$fwer0.05.Z] = 0

writeNIfTI(newZ, '~/pTFCEtest/pTFCE_Zthresholded.nii')
writeNIfTI(pTFCE$p, '~/pTFCEtest/pTFCE_P.nii')

alternativeZ = antsImageClone(lsm$zmap.img)
range(alternativeZ)
alternativeZ[alternativeZ < pTFCE$fwer0.05.Z] = 0

antsImageWrite(alternativeZ, '~/pTFCEtest/zmap_img_PTFCEthresholded.nii.gz')
spisakt commented 5 years ago

Hi @dorianps

what you wrote is typically experienced when GRF Theory does not apply for the images or image smoothness estimation is flawed for some other reason. In this case pTFCE can also "dehance" activation, especially if it's a very "small but high" peak. Can that be the problem with your input Z-score image?

Cheers, Tamas

dorianps commented 5 years ago

It might be, the peak on my image is ~z=15 if I remember correctly. The data is also from lesions, which have nasty and unpredictable spatial distributions, I guess GRF is not very good for these type of data either.

Do you know any regular TFCE implementation in R?

Thank you Dorian

On Tue, Apr 2, 2019 at 8:25 AM Tamas Spisak notifications@github.com wrote:

Hi @dorianps https://github.com/dorianps

what you wrote is typically experienced when GRF Theory does not apply for the images or image smoothness estimation is flawed for some other reason. In this case pTFCE can also "dehance" activation, especially if it's a very "small but high" peak. Can that be the problem with your input Z-score image?

Cheers, Tamas

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/spisakt/pTFCE/issues/4#issuecomment-478972263, or mute the thread https://github.com/notifications/unsubscribe-auth/AIqafXBN3Nma49zWwMakahKCYFJQMiC0ks5vc0xAgaJpZM4cXA-X .

spisakt commented 5 years ago

Hi Dorian,

No, but please note that the "free-parameters" of TFCE are also optimised for GRF-based null distribution. The permutation-based pTFCE version might be the solution, but I am still working on that.

Cheers, Tamas

dorianps commented 5 years ago

Alright, thanks for letting me know.

On Wed, Apr 10, 2019, 10:53 AM Tamas Spisak notifications@github.com wrote:

Hi Dorian,

No, but please note that the "free-parameters" of TFCE are also optimised for GRF-based null distribution. The permutation-based pTFCE version might be the solution, but I am still working on that.

Cheers, Tamas

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/spisakt/pTFCE/issues/4#issuecomment-481724463, or mute the thread https://github.com/notifications/unsubscribe-auth/AIqafTB10gCpRMDZGhkT_eCbMz4bFV0Mks5vffrMgaJpZM4cXA-X .