External Email - Use Caution
Hi again,
We decided to run mris_glmfit using the guide for longitudinal two stage model. We are not able to run the first script:
long_mris_slopes --qdec qdec.table.dat \
--meas thickness \
--hemi lh \
--sd /mnt/c/CogimmunStudy/FS \
--do-pc1 --do-label \
--time weeks \
--fwhm 15 \
--qcache fsaverage \
--stack-pc1 lh.testretest.thickness-pc1.stack.mgh \
--isec-labels lh.testretest.fsaverage.cortex.label
The error:
"Traceback (most recent call last): File "/usr/local/freesurfer/7.4.1/python/scripts/long_mris_slopes", line 1005, in <module> if fwhm > 0: TypeError: '>' not supported between instances of 'str' and 'int'"
We have made both a bash and a python script in our subject directory trying to solve the problem, but without any results.
bash:
#!/bin/bash
# Source the FreeSurfer environment
source /usr/local/freesurfer/SetUpFreeSurfer.sh
# Run the Python script to check the fwhm value
fwhm=$(./check_fwhm.py)
if [ $? -ne 0 ]; then
echo "Error: Invalid fwhm value received from Python script."
exit 1
fi
# Convert fwhm to integer explicitly
fwhm=$((fwhm))
# Check if fwhm is a valid positive integer
if ! [[ $fwhm =~ ^[1-9][0-9]*$ ]]; then
echo "Error: Invalid fwhm value $fwhm. Expected a positive integer greater than 0."
exit 1
fi
# Run long_mris_slopes with the specified parameters
long_mris_slopes --qdec ./qdec.table.dat \
--meas thickness \
--hemi lh \
--sd /mnt/c/CogimmunStudy/FS \
--do-avg --do-rate --do-pc1 --do-spc --do-stack --do-label \
--time weeks \
--fwhm $fwhm \
--qcache fsaverage \
--stack-pc1 lh.thickness-pc1.stack.mgh \
--isec-labels lh.fsaverage.cortex.label
python:
#!/usr/bin/env python3
import sys
def check_fwhm_value():
# Simulate or retrieve the FWHM value, for example:
fwhm = 15 # Replace with your actual method of retrieving FWHM
# Validate the FWHM value (optional)
try:
fwhm = int(fwhm)
if fwhm <= 0:
raise ValueError("FWHM must be a positive integer greater than 0.")
except ValueError as ve:
print(f"Error: {ve}", file=sys.stderr)
sys.exit(1)
return fwhm
if __name__ == "__main__":
fwhm = check_fwhm_value()
print(fwhm)
Can you guide us to move on with the analysis?
Best,
Josefine
Fra: Josefine Tingdal Taube Danielsen
Sendt: 10. juli 2024 11:31
Til: freesurfer@nmr.mgh.harvard.edu <freesurfer@nmr.mgh.harvard.edu>
Emne: Longitudinal analyses using Repeated measures anova
Hi Freesurfer support,
I'm using Freesurfer version 7.4.1 and Ubuntu 22_x86_64. freesurfer-linux-ubuntu22_x86_64-7.4.1-20230614-7eb8460.
I'm trying to run longitudinal analysis using Repeated Measures Anova (https://surfer.nmr.mgh.harvard.edu/fswiki/RepeatedMeasuresAnova).
My study has 2 groups (MM=patient group and HC=healthy controls) and 2 time points (1 and 2). I am looking at cortical thickness and cortical volume.
Here is some information:
We have been using these Contrast files:
# Create 1-vs-2 contrast file
echo "0 0 1" > 1-vs-2.mtx
# Create group-effect contrast file
echo "0 1 0" > group-effect.mtx
# Create interaction contrast file
echo "0 1 -1" > interaction.mtx
# Create mean contrast file
echo "1 0 0" > mean.mtxfree
And then followed this:
Preproc using FSGD
mris_preproc --target fsaverage --hemi lh --meas thickness --out lh.thickness.mgh --fsgd rmanova.fsgd
Smooth data
mri_surf2surf --s fsaverage --hemi lh --fwhm 5 --sval lh.thickness.mgh --tval lh.thickness.sm05.mgh
Run GLM fit
mri_glmfit --glmdir lh.rmanova --y lh.thickness.sm05.mgh --fsgd rmanova.fsgd doss \
--C 1-vs-2.mtx --C group-effect.mtx --C interaction.mtx --C mean.mtx \
--surface fsaverage lh
This was our results:
INFO: gd2mtx_method is doss Reading source surface /mnt/c/CogimmunStudy/FS/fsaverage/surf/lh.white Number of vertices 163842 Number of faces 327680 Total area 65417.000000 AvgVtxArea 0.399269 AvgVtxDist 0.721953 StdVtxDist 0.195472 7.4.1 cwd /mnt/c/CogimmunStudy/FS
cmdline mri_glmfit --glmdir lh.rmanova --y lh.thickness.sm05.mgh --fsgd rmanova.fsgd doss --C 1-vs-2.mtx --C group-effect.mtx --C interaction.mtx --C mean.mtx --surface fsaverage lh sysname Linux hostname D56979 machine x86_64 user josdan FixVertexAreaFlag
= 1 UseMaskWithSmoothing 1 OneSampleGroupMean 0 y /mnt/c/CogimmunStudy/FS/lh.thickness.sm05.mgh logyflag 0 usedti 0 FSGD rmanova.fsgd labelmask /mnt/c/CogimmunStudy/FS/fsaverage/label/lh.cortex.label maskinv 0 glmdir lh.rmanova IllCondOK 0 ReScaleX 1 DoFFx
0 SigUseDouble 1 Creating output directory lh.rmanova Loading y from /mnt/c/CogimmunStudy/FS/lh.thickness.sm05.mgh ... done reading. INFO: gd2mtx_method is doss Saving design matrix to lh.rmanova/Xg.dat Computing normalized matrix Normalized matrix condition
is 1 Matrix condition is 3.15 Found 149955 points in label. Pruning voxels by thr: 1.175494e-38 Found 149955 voxels in mask Saving mask to lh.rmanova/mask.mgh Reshaping mriglm->mask... search space = 74612.577841 DOF = 123 Starting fit and test Fit completed
in 0.0220333 minutes Computing spatial AR1 on surface Residual: ar1mn=0.986733, ar1std=0.003725, gstd=3.501824, fwhm=8.246166 Writing results 1-vs-2 maxvox sig=-2.06583 F=7.13254 at index 102162 0 0 seed=1720706961 Computing efficiency group-effect maxvox
sig=114.013 F=8295.3 at index 155689 0 0 seed=1720706961 Computing efficiency interaction maxvox sig=106.775 F=6297.15 at index 64378 0 0 seed=1720706961 Computing efficiency mean maxvox sig=133.337 F=17231.6 at index 155689 0 0 seed=1720706961 Computing efficiency
mri_glmfit done
Now our questions:
-
Have we been using the right contrasts?
-
Do the results look realistic?
-
Is it possible to have some more information about results (e.g. summary, areas being significant, visualization, sig.mgh, t-values, p-values not i -log10)?
Thank you!
Best,
Josefine Danielsen