extract mean value of cluster

How to extract the average value of the statistical parameter map ( For example: VMHC map) of 1000 subjects through a mask file (i.e., a cluster obtained by group analysis)?

Hi-

Can we clarify this first? Do you want an average of an ROI per subject, and then average of that across all subjects? Or do you want a voxelwise average acroos all subjects?

–pt

I only want an average of an ROI per subject.

I have obtained:

  1. a table (.csv) .
    look something like:
    Subj Group InputFile

subj0046 patient subj.0046.nii

subj0047 patient subj.0047.nii

subj0048 patient subj.0048.nii

subj0049 control subj.0049.nii

subj1000 control subj.1000.nii

  1. A mask file.

3.1000 VMHC map (.nii) (i.e., A R-fMRI indices, corresponds to the functional connectivity between any pair of symmetric inter-hemispheric voxels)

I only want an average VMHC of an ROI per subject.

The output table will look something like:

Subj Group InputFile mean_VMHC (ROI)

subj0046 patient subj.0046.nii xxx

subj0047 patient subj.0047.nii xxx

subj0048 patient subj.0048.nii xxx

subj0049 control subj.0049.nii xxx

subj1000 control subj.1000.nii xxx

The main command you want to calculate the average value of an INPUT_DSET within a MASK_DSET is:


3dmaskave -mask MASK_DSET INPUT_DSET

You are asking for larger scripting advice. I will take your example things literally (spacing, names, etc.)—even though you mentioned a CSV, your text file did not contain commas to separate values in a row, so neither did my example. I made this text file:


Subj Group InputFile
subj0046 patient subj.0046.nii
subj0047 patient subj.0047.nii
subj0048 patient subj.0048.nii
subj0049 control subj.0049.nii

I also made example/test 3D volumes with those names:


3dcalc -a jRandomDataset:5,5,5,1 -expr 'a' -prefix subj.0046.nii

etc. I also made a mask file to match:


3dcalc -a jRandomDataset:5,5,5,1 -expr '1' -prefix subj.MASK.nii

NB: These are not real datasets you would want to use (they are tiny 3D volumes with random numbers and a “full” mask), I just wanted some placeholders to be able to run a test script (below).

I then made+ran the following script:


#!/bin/tcsh

# just names of things
set file_old  = "file.txt"         # exists
set file_new  = "file_NEW.txt"     # new one to be created

set dset_mask = subj.MASK.nii

set nlines = `cat ${file_old} | wc -l`

# we assume that line 1 is a "header", so just copy it:
set line = `sed -n 1p "${file_old}"`
echo "${line} AVE" > "${file_new}"

foreach i ( `seq 2 1 ${nlines}` )

    set line = `sed -n ${i}p "${file_old}"`

    set dset = ${line[3]}

    set ave  = `3dmaskave -quiet -mask ${dset_mask} ${dset}`

    echo "${line} ${ave}" >> "${file_new}"
end

… by which this was created:


Subj Group InputFile AVE
subj0046 patient subj.0046.nii 0.126604
subj0047 patient subj.0047.nii -0.0212304
subj0048 patient subj.0048.nii 0.0762452
subj0049 control subj.0049.nii 0.0418862

Is that what you want? (This all depends on your mask being accurate, etc.)

–pt

If you have multiple mask ROIs, then consider 3dROIstats:

3dROIstats -mask mask+orig. ‘func_slim+orig[1]’