Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
melodic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FSL
melodic
Commits
5825413c
Commit
5825413c
authored
17 years ago
by
Christian Beckmann
Browse files
Options
Downloads
Patches
Plain Diff
convergence
parent
1e6ab0b1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
meldata.cc
+46
-22
46 additions, 22 deletions
meldata.cc
melhlprfns.cc
+1
-1
1 addition, 1 deletion
melhlprfns.cc
melica.cc
+11
-3
11 additions, 3 deletions
melica.cc
meloptions.h
+1
-1
1 addition, 1 deletion
meloptions.h
melreport.cc
+1
-1
1 addition, 1 deletion
melreport.cc
with
60 additions
and
28 deletions
meldata.cc
+
46
−
22
View file @
5825413c
...
@@ -63,7 +63,7 @@ namespace Melodic{
...
@@ -63,7 +63,7 @@ namespace Melodic{
}
}
meanC
=
mean
(
tmpData
,
2
);
meanC
=
mean
(
tmpData
,
2
);
tmpData
=
remmean
(
tmpData
,
2
);
//
tmpData = remmean(tmpData,2);
//convert to power spectra
//convert to power spectra
if
(
opts
.
pspec
.
value
()){
if
(
opts
.
pspec
.
value
()){
...
@@ -86,7 +86,7 @@ namespace Melodic{
...
@@ -86,7 +86,7 @@ namespace Melodic{
//variance - normalisation
//variance - normalisation
if
(
opts
.
varnorm
.
value
()){
if
(
opts
.
varnorm
.
value
()){
message
(
" Normalising by voxel-wise variance ..."
);
message
(
" Normalising by voxel-wise variance ..."
);
stdDev
=
varnorm
(
tmpData
,
tmpData
.
Nrows
(),
2.3
);
stdDev
=
varnorm
(
tmpData
,
std
::
min
(
30
,
tmpData
.
Nrows
()
-
1
)
,
2.3
);
stdDevi
=
pow
(
stdDev
,
-
1
);
stdDevi
=
pow
(
stdDev
,
-
1
);
message
(
" done"
<<
endl
);
message
(
" done"
<<
endl
);
}
}
...
@@ -131,9 +131,10 @@ namespace Melodic{
...
@@ -131,9 +131,10 @@ namespace Melodic{
void
MelodicData
::
set_TSmode
()
void
MelodicData
::
set_TSmode
()
{
{
message
(
"Calculating T- and S-modes "
<<
endl
);
Matrix
tmp
,
tmpT
,
tmpS
,
tmpT2
,
tmpS2
;
Matrix
tmp
,
tmpT
,
tmpS
,
tmpT2
,
tmpS2
;
tmp
=
expand_dimred
(
mixMatrix
);
tmp
=
expand_dimred
(
mixMatrix
);
saveascii
(
tmp
,
"exp"
);
saveascii
(
mixMatrix
,
"mix"
);
tmpT
=
zeros
(
tmp
.
Nrows
()
/
numfiles
,
tmp
.
Ncols
());
tmpT
=
zeros
(
tmp
.
Nrows
()
/
numfiles
,
tmp
.
Ncols
());
tmpS
=
zeros
(
numfiles
,
tmp
.
Ncols
());
tmpS
=
zeros
(
numfiles
,
tmp
.
Ncols
());
krfact
(
tmp
,
tmpT
,
tmpS
);
krfact
(
tmp
,
tmpT
,
tmpS
);
...
@@ -175,11 +176,15 @@ namespace Melodic{
...
@@ -175,11 +176,15 @@ namespace Melodic{
// bool tmpvarnorm = opts.varnorm.value();
// bool tmpvarnorm = opts.varnorm.value();
// opts.varnorm.set_T(false);
// opts.varnorm.set_T(false);
alldat
=
process_file
(
opts
.
inputfname
.
value
().
at
(
0
),
numfiles
)
/
numfiles
;
alldat
=
process_file
(
opts
.
inputfname
.
value
().
at
(
0
),
numfiles
)
/
numfiles
;
for
(
int
ctr
=
1
;
ctr
<
numfiles
;
ctr
++
){
if
(
opts
.
debug
.
value
())
tmpData
=
process_file
(
opts
.
inputfname
.
value
().
at
(
ctr
),
numfiles
);
save4D
(
alldat
,
string
(
"preproc_dat"
)
+
num2str
(
1
));
for
(
int
ctr
=
1
;
ctr
<
numfiles
;
ctr
++
){
tmpData
=
process_file
(
opts
.
inputfname
.
value
().
at
(
ctr
),
numfiles
);
if
(
opts
.
debug
.
value
())
save4D
(
tmpData
/
numfiles
,
string
(
"preproc_dat"
)
+
num2str
(
ctr
+
1
));
alldat
+=
tmpData
/
numfiles
;
alldat
+=
tmpData
/
numfiles
;
}
}
// opts.varnorm.set_T(tmpvarnorm);
// opts.varnorm.set_T(tmpvarnorm);
//variance - normalisation
//variance - normalisation
// if(opts.varnorm.value()){
// if(opts.varnorm.value()){
...
@@ -199,25 +204,37 @@ namespace Melodic{
...
@@ -199,25 +204,37 @@ namespace Melodic{
if
(
numfiles
>
1
)
if
(
numfiles
>
1
)
message
(
endl
<<
"Initial data size : "
<<
alldat
.
Nrows
()
<<
" x "
<<
alldat
.
Ncols
()
<<
endl
<<
endl
);
message
(
endl
<<
"Initial data size : "
<<
alldat
.
Nrows
()
<<
" x "
<<
alldat
.
Ncols
()
<<
endl
<<
endl
);
if
(
opts
.
debug
.
value
())
save4D
(
alldat
,
"alldat"
);
//estimate model order
//estimate model order
ColumnVector
tmpPPCA
;
ColumnVector
tmpPPCA
;
RowVector
AdjEV
,
PercEV
;
RowVector
AdjEV
,
PercEV
;
Matrix
Corr
,
tmpE
;
Matrix
Corr
,
tmpE
;
int
order
;
int
order
;
order
=
ppca_dim
(
alldat
,
RXweight
,
tmpPPCA
,
AdjEV
,
PercEV
,
Corr
,
pcaE
,
pcaD
,
Resels
,
opts
.
pca_est
.
value
());
order
=
ppca_dim
(
remmean
(
alldat
,
2
),
RXweight
,
tmpPPCA
,
AdjEV
,
PercEV
,
Corr
,
pcaE
,
pcaD
,
Resels
,
opts
.
pca_est
.
value
());
if
(
opts
.
pca_dim
.
value
()
==
0
){
if
(
opts
.
pca_dim
.
value
()
==
0
){
opts
.
pca_dim
.
set_T
(
order
);
opts
.
pca_dim
.
set_T
(
order
);
PPCA
=
tmpPPCA
;
PPCA
=
tmpPPCA
;
}
}
order
=
opts
.
pca_dim
.
value
();
order
=
opts
.
pca_dim
.
value
();
calc_white
(
pcaE
,
pcaD
,
order
,
whiteMatrix
,
dewhiteMatrix
);
calc_white
(
pcaE
,
pcaD
,
order
,
whiteMatrix
,
dewhiteMatrix
);
if
(
opts
.
debug
.
value
()){
outMsize
(
"pcaE"
,
pcaE
);
saveascii
(
pcaE
,
"pcaE"
);
outMsize
(
"pcaD"
,
pcaD
);
saveascii
(
pcaD
,
"pcaD"
);
outMsize
(
"AdjEV"
,
AdjEV
);
saveascii
(
AdjEV
,
"AdjEV"
);
outMsize
(
"PercEV"
,
PercEV
);
saveascii
(
PercEV
,
"PercEV"
);
outMsize
(
"tmpPPCA"
,
tmpPPCA
);
saveascii
(
tmpPPCA
,
"tmpPPCA"
);
outMsize
(
"whiteMatrix"
,
whiteMatrix
);
saveascii
(
whiteMatrix
,
"whiteMatrix"
);
outMsize
(
"dewhiteMatrix"
,
dewhiteMatrix
);
saveascii
(
dewhiteMatrix
,
"dewhiteMatrix"
);
cerr
<<
"Order: "
<<
order
<<
endl
;
}
EV
=
AdjEV
;
EV
=
AdjEV
;
EVP
=
PercEV
;
EVP
=
PercEV
;
if
(
numfiles
==
1
){
if
(
numfiles
==
1
){
Data
=
alldat
;
Data
=
alldat
;
Matrix
tmp
=
Identity
(
Data
.
Nrows
());
Matrix
tmp
=
Identity
(
Data
.
Nrows
());
...
@@ -230,15 +247,21 @@ namespace Melodic{
...
@@ -230,15 +247,21 @@ namespace Melodic{
// if(opts.varnorm.value())
// if(opts.varnorm.value())
// varnorm(tmpData,stdDev);
// varnorm(tmpData,stdDev);
// whiten (separate / joint)
// whiten (separate / joint)
Matrix
newWM
,
newDWM
;
if
(
!
opts
.
joined_whiten
.
value
()){
if
(
!
opts
.
joined_whiten
.
value
()){
message
(
" Individual whitening in a "
<<
order
<<
" dimensional subspace "
<<
endl
);
message
(
" Individual whitening in a "
<<
order
<<
" dimensional subspace "
<<
endl
);
std_pca
(
tmpData
,
RXweight
,
Corr
,
pcaE
,
pcaD
);
std_pca
(
tmpData
,
RXweight
,
Corr
,
pcaE
,
pcaD
);
calc_white
(
pcaE
,
pcaD
,
order
,
whiteMatrix
,
dewhiteMatrix
);
calc_white
(
pcaE
,
pcaD
,
order
,
newWM
,
newDWM
);
}
else
{
std_pca
(
whiteMatrix
*
tmpData
,
RXweight
,
Corr
,
pcaE
,
pcaD
);
calc_white
(
pcaE
,
pcaD
,
order
,
newWM
,
newDWM
);
newDWM
=
(
dewhiteMatrix
*
newDWM
);
newWM
=
(
newWM
*
whiteMatrix
);
}
}
tmpData
=
whiteMatrix
*
tmpData
;
DWM
.
push_back
(
newDWM
)
;
D
WM
.
push_back
(
d
ew
hiteMatrix
);
WM
.
push_back
(
n
ew
WM
);
WM
.
push_back
(
whiteMatrix
)
;
tmpData
=
newWM
*
tmpData
;
//concatenate Data
//concatenate Data
if
(
Data
.
Storage
()
==
0
)
if
(
Data
.
Storage
()
==
0
)
...
@@ -251,7 +274,8 @@ namespace Melodic{
...
@@ -251,7 +274,8 @@ namespace Melodic{
message
(
" Data size : "
<<
Data
.
Nrows
()
<<
" x "
<<
Data
.
Ncols
()
<<
endl
);
message
(
" Data size : "
<<
Data
.
Nrows
()
<<
" x "
<<
Data
.
Ncols
()
<<
endl
);
meanC
=
mean
(
Data
,
2
);
meanC
=
mean
(
Data
,
2
);
if
(
opts
.
debug
.
value
())
save4D
(
Data
,
"concat_data"
);
//save the mean & mask
//save the mean & mask
save_volume
(
Mask
,
logger
.
appendDir
(
"mask"
));
save_volume
(
Mask
,
logger
.
appendDir
(
"mask"
));
save_volume
(
Mean
,
logger
.
appendDir
(
"mean"
));
save_volume
(
Mean
,
logger
.
appendDir
(
"mean"
));
...
@@ -295,17 +319,17 @@ namespace Melodic{
...
@@ -295,17 +319,17 @@ namespace Melodic{
//read in post-proc design matrices etc
//read in post-proc design matrices etc
if
(
opts
.
fn_Tdesign
.
value
().
length
()
>
0
)
if
(
opts
.
fn_Tdesign
.
value
().
length
()
>
0
)
Tdes
=
read_
vest
(
opts
.
fn_Tdesign
.
value
());
Tdes
=
read_
ascii_matrix
(
opts
.
fn_Tdesign
.
value
());
if
(
opts
.
fn_Sdesign
.
value
().
length
()
>
0
)
if
(
opts
.
fn_Sdesign
.
value
().
length
()
>
0
)
Sdes
=
read_
vest
(
opts
.
fn_Sdesign
.
value
());
Sdes
=
read_
ascii_matrix
(
opts
.
fn_Sdesign
.
value
());
if
(
opts
.
fn_Tcon
.
value
().
length
()
>
0
)
if
(
opts
.
fn_Tcon
.
value
().
length
()
>
0
)
Tcon
=
read_
vest
(
opts
.
fn_Tcon
.
value
());
Tcon
=
read_
ascii_matrix
(
opts
.
fn_Tcon
.
value
());
if
(
opts
.
fn_Scon
.
value
().
length
()
>
0
)
if
(
opts
.
fn_Scon
.
value
().
length
()
>
0
)
Scon
=
read_
vest
(
opts
.
fn_Scon
.
value
());
Scon
=
read_
ascii_matrix
(
opts
.
fn_Scon
.
value
());
if
(
opts
.
fn_TconF
.
value
().
length
()
>
0
)
if
(
opts
.
fn_TconF
.
value
().
length
()
>
0
)
TconF
=
read_
vest
(
opts
.
fn_TconF
.
value
());
TconF
=
read_
ascii_matrix
(
opts
.
fn_TconF
.
value
());
if
(
opts
.
fn_SconF
.
value
().
length
()
>
0
)
if
(
opts
.
fn_SconF
.
value
().
length
()
>
0
)
SconF
=
read_
vest
(
opts
.
fn_SconF
.
value
());
SconF
=
read_
ascii_matrix
(
opts
.
fn_SconF
.
value
());
Tdes
=
remmean
(
Tdes
,
1
);
Tdes
=
remmean
(
Tdes
,
1
);
Sdes
=
remmean
(
Sdes
,
1
);
Sdes
=
remmean
(
Sdes
,
1
);
...
...
This diff is collapsed.
Click to expand it.
melhlprfns.cc
+
1
−
1
View file @
5825413c
...
@@ -132,7 +132,7 @@ namespace Melodic{
...
@@ -132,7 +132,7 @@ namespace Melodic{
Matrix
tmpE
,
white
,
dewhite
;
Matrix
tmpE
,
white
,
dewhite
;
RowVector
tmpD
,
tmpD2
;
RowVector
tmpD
,
tmpD2
;
std_pca
(
in
,
Corr
,
tmpE
,
tmpD
);
std_pca
(
remmean
(
in
,
2
)
,
Corr
,
tmpE
,
tmpD
);
calc_white
(
tmpE
,
tmpD
,
dim
,
white
,
dewhite
);
calc_white
(
tmpE
,
tmpD
,
dim
,
white
,
dewhite
);
Matrix
ws
=
white
*
in
;
Matrix
ws
=
white
*
in
;
...
...
This diff is collapsed.
Click to expand it.
melica.cc
+
11
−
3
View file @
5825413c
...
@@ -32,7 +32,7 @@ namespace Melodic{
...
@@ -32,7 +32,7 @@ namespace Melodic{
// see www.cis.hut.fi/projects/ica/fastica/
// see www.cis.hut.fi/projects/ica/fastica/
//initialize matrices
//initialize matrices
Matrix
redUMM_old
;
Matrix
redUMM_old
,
redUMM_veryold
;
Matrix
tmpU
;
Matrix
tmpU
;
//srand((unsigned int)timer(NULL));
//srand((unsigned int)timer(NULL));
...
@@ -50,12 +50,13 @@ namespace Melodic{
...
@@ -50,12 +50,13 @@ namespace Melodic{
symm_orth
(
redUMM
);
symm_orth
(
redUMM
);
int
itt_ctr
,
itt_ctr2
=
1
,
cum_itt
=
0
;
int
itt_ctr
,
itt_ctr2
=
1
,
cum_itt
=
0
,
newmaxitts
=
opts
.
maxNumItt
.
value
()
;
double
minAbsSin
=
1.0
;
double
minAbsSin
=
1.0
;
if
(
opts
.
approach
.
value
()
==
string
(
"tica"
))
if
(
opts
.
approach
.
value
()
==
string
(
"tica"
))
opts
.
maxNumItt
.
set_T
(
opts
.
rank1interval
.
value
());
opts
.
maxNumItt
.
set_T
(
opts
.
rank1interval
.
value
());
do
{
// TICA loop
do
{
// TICA loop
itt_ctr
=
1
;
itt_ctr
=
1
;
redUMM_veryold
=
redUMM
;
do
{
// da loop!!!
do
{
// da loop!!!
redUMM_old
=
redUMM
;
redUMM_old
=
redUMM
;
//calculate IC estimates
//calculate IC estimates
...
@@ -92,6 +93,9 @@ namespace Melodic{
...
@@ -92,6 +93,9 @@ namespace Melodic{
// orthogonalize the unmixing-matrix
// orthogonalize the unmixing-matrix
symm_orth
(
redUMM
);
symm_orth
(
redUMM
);
if
(
opts
.
approach
.
value
()
==
string
(
"tica"
)){
message
(
" TICA:"
);
}
//termination condition : angle between old and new < epsilon
//termination condition : angle between old and new < epsilon
minAbsSin
=
1
-
diag
(
abs
(
redUMM
.
t
()
*
redUMM_old
)).
Minimum
();
minAbsSin
=
1
-
diag
(
abs
(
redUMM
.
t
()
*
redUMM_old
)).
Minimum
();
message
(
" Step no. "
<<
cum_itt
+
itt_ctr
<<
" change : "
<<
minAbsSin
<<
endl
);
message
(
" Step no. "
<<
cum_itt
+
itt_ctr
<<
" change : "
<<
minAbsSin
<<
endl
);
...
@@ -113,9 +117,12 @@ namespace Melodic{
...
@@ -113,9 +117,12 @@ namespace Melodic{
outMsize
(
" 2nd unmmixing matrix "
,
temp
);
outMsize
(
" 2nd unmmixing matrix "
,
temp
);
redUMM
=
melodat
.
get_white
()
*
temp
;
redUMM
=
melodat
.
get_white
()
*
temp
;
outMsize
(
" redUMM "
,
redUMM
);
outMsize
(
" redUMM "
,
redUMM
);
minAbsSin
=
1
-
diag
(
abs
(
redUMM
.
t
()
*
redUMM_veryold
)).
Minimum
();
message
(
" Step no. "
<<
cum_itt
+
itt_ctr
<<
" change : "
<<
minAbsSin
<<
endl
);
if
(
abs
(
minAbsSin
)
<
opts
.
epsilon
.
value
()){
break
;}
}
}
}
while
((
itt_ctr2
<
3
||
itt_ctr
>=
opts
.
maxNumItt
.
value
())
&&
}
while
((
itt_ctr2
<
3
||
itt_ctr
>=
opts
.
maxNumItt
.
value
())
&&
(
opts
.
approach
.
value
()
==
string
(
"tica"
))
&&
cum_itt
<
100
*
opts
.
maxNumItt
.
value
()
);
(
opts
.
approach
.
value
()
==
string
(
"tica"
))
&&
cum_itt
<
newmaxitts
);
if
(
itt_ctr
>=
opts
.
maxNumItt
.
value
()){
if
(
itt_ctr
>=
opts
.
maxNumItt
.
value
()){
cerr
<<
" No convergence after "
<<
cum_itt
<<
" steps "
<<
endl
;
cerr
<<
" No convergence after "
<<
cum_itt
<<
" steps "
<<
endl
;
...
@@ -459,6 +466,7 @@ namespace Melodic{
...
@@ -459,6 +466,7 @@ namespace Melodic{
melodat
.
set_IC
(
temp
);
melodat
.
set_IC
(
temp
);
melodat
.
set_ICstats
(
scales
);
melodat
.
set_ICstats
(
scales
);
melodat
.
sort
();
melodat
.
sort
();
message
(
"Calculating T- and S-modes "
<<
endl
);
melodat
.
set_TSmode
();
melodat
.
set_TSmode
();
}
}
...
...
This diff is collapsed.
Click to expand it.
meloptions.h
+
1
−
1
View file @
5825413c
...
@@ -251,7 +251,7 @@ class MelodicOptions {
...
@@ -251,7 +251,7 @@ class MelodicOptions {
false
,
requires_argument
),
false
,
requires_argument
),
fn_TconF
(
string
(
"--Tconf"
),
string
(
""
),
fn_TconF
(
string
(
"--Tconf"
),
string
(
""
),
string
(
" F-contrast matrix across time-domain"
),
string
(
" F-contrast matrix across time-domain"
),
false
,
requires_argument
),
false
,
requires_argument
,
false
),
fn_Sdesign
(
string
(
"--Sdes"
),
string
(
""
),
fn_Sdesign
(
string
(
"--Sdes"
),
string
(
""
),
string
(
" design matrix across subject-domain"
),
string
(
" design matrix across subject-domain"
),
false
,
requires_argument
),
false
,
requires_argument
),
...
...
This diff is collapsed.
Click to expand it.
melreport.cc
+
1
−
1
View file @
5825413c
...
@@ -692,7 +692,7 @@ namespace Melodic{
...
@@ -692,7 +692,7 @@ namespace Melodic{
newplot
.
add_label
(
"dim. estimate"
);
newplot
.
add_label
(
"dim. estimate"
);
}
}
//CB's latest BUG!!!
newplot.grid_swapdefault();
newplot
.
grid_swapdefault
();
newplot
.
timeseries
(
what
,
newplot
.
timeseries
(
what
,
report
.
appendDir
(
"EVplot.png"
),
report
.
appendDir
(
"EVplot.png"
),
string
(
"Eigenspectrum Analysis"
),
string
(
"Eigenspectrum Analysis"
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment