Commit 93332ce7 authored by Stephen Smith's avatar Stephen Smith Committed by Duncan Mortimer
Browse files

Updates for 1.067, includes bb_fix, HCP7T training data and multiple updates...

Updates for 1.067, includes bb_fix, HCP7T training data and multiple updates to MATLAB and R functions
parent f9623c81
#!/bin/sh
# bb_fix - wrapper script for FIX, for UK Biobank pipelines
#
# Stephen Smith, FMRIB Analysis Group
#
# Copyright (C) 2015 University of Oxford
#
# SHCOPYRIGHT
FSL_FIXDIR=$( cd $(dirname $0) ; pwd)
export FSL_FIXDIR
# All fix settings are held in the settings.sh file - edit this file to suit your setup
. ${FSL_FIXDIR}/settings.sh
#############################################################
[ "$1" = "" ] && exit
cd $1/fMRI/rfMRI.ica
imcp ../../T1/T1_fast/T1_brain_pveseg reg/highres_pveseg
invwarp --ref=reg/example_func -w reg/example_func2standard_warp -o reg/standard2example_func_warp
${FSL_FIXDIR}/fix . ${FSL_FIXDIR}/training_files/UKBiobank.RData 20 -m -h 100
mkdir -p reg_standard
applywarp --ref=reg/standard --in=filtered_func_data_clean --out=reg_standard/filtered_func_data_clean --warp=reg/example_func2standard_warp --interp=spline
fslmaths reg_standard/filtered_func_data_clean -mas $BBDIR/fbp/templates/MNI152_T1_2mm_brain_mask_bin reg_standard/filtered_func_data_clean
fslmaths reg_standard/filtered_func_data_clean -Tstd -bin reg_standard/filtered_func_data_clean_stdmask
......@@ -26,7 +26,8 @@ features(1) = max(C1(1:6));
features(2) = max(C1(7:end));
features(3) = max(features);
regModel = regress(timeSeries/(eps+std(timeSeries)), [ones(size(timeSeries)) TSS]);
%regModel = regress(timeSeries/(eps+std(timeSeries)), [ones(size(timeSeries)) TSS]);
regModel = pinv([ones(size(timeSeries)) TSS],1e-6)*timeSeries/(eps+std(timeSeries));
regModel = sort(abs(regModel(2:end)));
features(4:6) = [regModel(end-1:end); mean(regModel(floor(end/2):end))];
......
......@@ -4,7 +4,11 @@ folders=$1
exfunc=${folders}/reg/example_func
fast -t 1 -o ${folders}/fix/fastsg ${folders}/reg/highres
if [ `imtest ${folders}/reg/highres_pveseg` = 1 ] ; then
imcp ${folders}/reg/highres_pveseg ${folders}/fix/fastsg_pveseg
else
fast -t 1 -o ${folders}/fix/fastsg ${folders}/reg/highres
fi
if [ `$FSLDIR/bin/imtest ${folders}/reg/wmparc` = 1 ] ; then
fslmaths ${folders}/reg/wmparc -mul 0 ${folders}/fix/subcort
......
......@@ -5,15 +5,31 @@ fixdir=$2
exfunc=$folders/reg/example_func
flirt -in $folders/reg/highres -ref $FSLDIR/data/standard/MNI152_T1_1mm_brain -omat $folders/fix/highres2std.mat
convert_xfm -omat $folders/fix/std2highres.mat -inverse $folders/fix/highres2std.mat
convert_xfm -omat $folders/fix/std2exfunc.mat -concat $folders/reg/highres2example_func.mat $folders/fix/std2highres.mat
for m in 0 1 2 3 ; do
flirt -in $fixdir/mask_files/sag_mask${m} -ref $exfunc -applyxfm -init ${folders}/fix/std2exfunc.mat -out ${folders}/fix/std1mm2exfunc${m} -datatype float
flirt -in $fixdir/mask_files/sag_mask${m}dil -ref $exfunc -applyxfm -init ${folders}/fix/std2exfunc.mat -out ${folders}/fix/std1mm2exfunc${m}dil -datatype float
flirt -in $fixdir/mask_files/sag_mask${m}dil2 -ref $exfunc -applyxfm -init ${folders}/fix/std2exfunc.mat -out ${folders}/fix/std1mm2exfunc${m}dil2 -datatype float
done
if [ `imtest ${folders}/reg/standard2example_func_warp` = 1 ] ; then
for m in 0 1 2 3 ; do
applywarp --in=$fixdir/mask_files/sag_mask${m} --ref=$exfunc -w ${folders}/reg/standard2example_func_warp -o ${folders}/fix/std1mm2exfunc${m}
applywarp --in=$fixdir/mask_files/sag_mask${m}dil --ref=$exfunc -w ${folders}/reg/standard2example_func_warp -o ${folders}/fix/std1mm2exfunc${m}dil
applywarp --in=$fixdir/mask_files/sag_mask${m}dil2 --ref=$exfunc -w ${folders}/reg/standard2example_func_warp -o ${folders}/fix/std1mm2exfunc${m}dil2
done
else
if [ -f ${folders}/reg/standard2example_func.mat ] ; then
/bin/cp ${folders}/reg/standard2example_func.mat $folders/fix/std2exfunc.mat
else
flirt -in $folders/reg/highres -ref $FSLDIR/data/standard/MNI152_T1_1mm_brain -omat $folders/fix/highres2std.mat
convert_xfm -omat $folders/fix/std2highres.mat -inverse $folders/fix/highres2std.mat
convert_xfm -omat $folders/fix/std2exfunc.mat -concat $folders/reg/highres2example_func.mat $folders/fix/std2highres.mat
fi
for m in 0 1 2 3 ; do
flirt -in $fixdir/mask_files/sag_mask${m} -ref $exfunc -applyxfm -init ${folders}/fix/std2exfunc.mat -out ${folders}/fix/std1mm2exfunc${m} -datatype float
flirt -in $fixdir/mask_files/sag_mask${m}dil -ref $exfunc -applyxfm -init ${folders}/fix/std2exfunc.mat -out ${folders}/fix/std1mm2exfunc${m}dil -datatype float
flirt -in $fixdir/mask_files/sag_mask${m}dil2 -ref $exfunc -applyxfm -init ${folders}/fix/std2exfunc.mat -out ${folders}/fix/std1mm2exfunc${m}dil2 -datatype float
done
fi
if [ `imtest $folders/reg/veins_exf` = 1 ] ; then
imcp $folders/reg/veins_exf ${folders}/fix/std1mm2exfunc0
......
......@@ -73,9 +73,11 @@ for(indx in c(1:6)) {
eval(parse(text = paste("svm.pol.prd",indx," <- attributes(predict(svm.pol",indx,", test.data.",indx,", probability=T))$probabilities[,2]", sep = "")))
# Tree
eval(parse(text = paste("ctree", indx, " = ctree", indx, "@update()", sep = "")))
eval(parse(text = paste("ctree.prd.test",indx," <- treeresponse(ctree",indx,", newdata = test.data.",indx,")", sep = "")))
eval(parse(text = paste("ctree.prob.test",indx," <- c(1:length(ctree.prd.test",indx,"))", sep = "")))
eval(parse(text = paste("for(i in c(1:length(ctree.prob.test",indx,"))){ctree.prob.test",indx,"[i] <- ctree.prd.test",indx,"[[i]][2]}", sep = "")))
# KNN
eval(parse(text = paste("tmp <- knn(train.data.",indx,"[,-dim(train.data.",indx,")[2]], test.data.",indx,", train.data.",indx,"[,dim(train.data.",indx,")[2]], k = k.knn, prob = T)", sep = "")))
eval(parse(text = paste("knn.test",indx," <- attributes(tmp)", sep = "")))
......
......@@ -7,6 +7,7 @@ if exist(sprintf('%s/.train',LOODIR)) == 2
pt=fopen(sprintf('%s/.train',LOODIR),'r');
bLOODIR=textscan(pt,'%s'); bLOODIR=char(bLOODIR{1}(1));
end
grot=tempname;
pp=fopen(sprintf('%s/.fixlist',LOODIR),'r');
thelist=textscan(pp,'%s');
......@@ -17,15 +18,15 @@ for ithresh=1:length(thresh)
f=char(thelist{1}(i));
call_fsl(sprintf('fslnvols %s/filtered_func_data.ica/melodic_IC > %s/grot',f,LOODIR));
Nics=load(sprintf('%s/grot',LOODIR));
call_fsl(sprintf('fslnvols %s/filtered_func_data.ica/melodic_IC > %s',f,grot));
Nics=load(sprintf('%s',grot));
system(sprintf('tail -n 1 %s/hand_labels_noise.txt | sed ''s/\\[//g'' | sed ''s/\\]//g'' | sed ''s/,//g'' > %s/grot',f,LOODIR));
hand=load(sprintf('%s/grot',LOODIR));
system(sprintf('tail -n 1 %s/hand_labels_noise.txt | sed ''s/\\[//g'' | sed ''s/\\]//g'' | sed ''s/,//g'' > %s',f,grot));
hand=load(sprintf('%s',grot));
system(sprintf('tail -n 1 %s/fix4melview_%s_thr%d.txt | sed ''s/\\[//g'' | sed ''s/\\]//g'' | sed ''s/,//g'' > %s/grot',f,bLOODIR,thresh(ithresh),LOODIR));
system(sprintf('tail -n 1 %s/fix4melview_%s_thr%d.txt | sed ''s/\\[//g'' | sed ''s/\\]//g'' | sed ''s/,//g'' > %s',f,bLOODIR,thresh(ithresh),grot));
try
fix=load(sprintf('%s/grot',LOODIR));
fix=load(sprintf('%s',grot));
catch
fix=[];
end
......
#!/bin/sh
# fix_diff - compare the noise component list from two classification output files
#
# Gholamreza Salimi-Khorshidi and Stephen Smith, FMRIB Analysis Group
#
# Copyright (C) 2012-2013 University of Oxford
#
# SHCOPYRIGHT
#############################################################
Usage() {
cat <<EOF
fix_diff <true_classification.txt> <fix_auto_classification.txt>
e.g.: fix_diff hand_labels_noise.txt fix4melview_HCP2000_thr5.txt
EOF
exit 1
}
#############################################################
[ "$2" = "" ] && Usage
in1=$1
in2=$2
i=1
while [ $i -lt `wc -l $in1 $in2 | tail -n 1 | awk '{print $1}'` ] ; do
in1y=`tail -n 1 $in1 | sed 's/\[/,/g' | sed 's/\]/,/g' | sed 's/ //g' | grep ,${i}, | wc -l`
in2y=`tail -n 1 $in2 | sed 's/\[/,/g' | sed 's/\]/,/g' | sed 's/ //g' | grep ,${i}, | wc -l`
if [ $in1y != $in2y ] ; then
if [ $in1y == 1 ] ; then
echo component $i only classed as noise in input 1
else
echo component $i only classed as noise in input 2
fi
fi
i=`echo "$i 1 + p" | dc -`
done
......@@ -12,7 +12,7 @@ end
[grota,grotb]=call_fsl('imtest mc/prefiltered_func_data_mcf_conf_hp');
if grotb==1
if isequal(str2num(grotb),1)
confounds=read_avw('mc/prefiltered_func_data_mcf_conf_hp');
confounds=functionnormalise(reshape(confounds,size(confounds,1),size(confounds,4))');
......
......@@ -71,7 +71,7 @@ if [ -f ../${fmri_orig}_Atlas.dtseries.nii ] ; then
fi
mkdir -p mc
if [ -a ../Movement_Regressors.txt ] ; then
if [ -f ../Movement_Regressors.txt ] ; then
cat ../Movement_Regressors.txt | awk '{ print $4 " " $5 " " $6 " " $1 " " $2 " " $3}' > mc/prefiltered_func_data_mcf.par
else
echo "ERROR: Movement_Regressors.txt not retrieved properly."
......@@ -88,7 +88,9 @@ $FSLDIR/bin/imln ../mean_func example_func
$FSLDIR/bin/makerot --theta=0 > highres2example_func.mat
if [ `$FSLDIR/bin/imtest ../../../../T2w` = 1 ] ; then
$FSLDIR/bin/fslmaths ../../../../T1w -div ../../../../T2w veins -odt float
$FSLDIR/bin/fslmaths veins -div `$FSLDIR/bin/fslstats veins -k ${FSL_FIXDIR}/mask_files/hcp_0.7mm_brain_mask -P 50` -mul 2.18 -thr 10 -min 50 -div 50 veins
$FSLDIR/bin/flirt -in ${FSL_FIXDIR}/mask_files/hcp_0.7mm_brain_mask -ref veins -out veinbrainmask -applyxfm
$FSLDIR/bin/fslmaths veinbrainmask -bin veinbrainmask
$FSLDIR/bin/fslmaths veins -div `$FSLDIR/bin/fslstats veins -k veinbrainmask -P 50` -mul 2.18 -thr 10 -min 50 -div 50 veins
$FSLDIR/bin/flirt -in veins -ref example_func -applyxfm -init highres2example_func.mat -out veins_exf
$FSLDIR/bin/fslmaths veins_exf -mas example_func veins_exf
fi
......
# Settings file for FIX
# Modify these settings based on your system setup
FIXVERSION=1.06
# (actually this version is 1.065 - see wiki page for details)
# (actually this version is 1.067 - see wiki page for details)
# Get the OS and CPU type
FSL_FIX_OS=`uname -s`
FSL_FIX_ARCH=`uname -m`
if [ -z "${FSL_FIXDIR}" ]; then
if [ "X$0" = "X-bash" ]; then
FSL_FIXDIR=$(pwd)
else
FSL_FIXDIR=$( cd $(dirname $0) ; pwd)
fi
export FSL_FIXDIR
fi
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment