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
52c7ffce
Commit
52c7ffce
authored
12 years ago
by
Christian Beckmann
Browse files
Options
Downloads
Patches
Plain Diff
MIGP v 0.2
parent
8cf9d9f0
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
meldata.cc
+91
-70
91 additions, 70 deletions
meldata.cc
meldata.h
+2
-1
2 additions, 1 deletion
meldata.h
meloptions.h
+13
-3
13 additions, 3 deletions
meloptions.h
with
106 additions
and
74 deletions
meldata.cc
+
91
−
70
View file @
52c7ffce
...
@@ -150,76 +150,83 @@ namespace Melodic{
...
@@ -150,76 +150,83 @@ namespace Melodic{
return
tmp
;
return
tmp
;
}
}
void
MelodicData
::
set_TSmode
()
void
MelodicData
::
set_TSmode
_depr
()
{
{
dbgmsg
(
string
(
"START: set_TSmode"
));
Matrix
tmp
,
tmpT
,
tmpS
,
tmpT2
,
tmpS2
,
tmpT3
;
Matrix
tmp
,
tmpT
,
tmpS
,
tmpT2
,
tmpS2
,
tmpT3
;
tmp
=
expand_dimred
(
mixMatrix
);
tmpT
=
zeros
(
tmp
.
Nrows
()
/
numfiles
,
tmp
.
Ncols
());
tmp
=
expand_dimred
(
mixMatrix
);
tmpS
=
ones
(
numfiles
,
tmp
.
Ncols
());
tmpT
=
zeros
(
tmp
.
Nrows
()
/
numfiles
,
tmp
.
Ncols
());
tmpS
=
ones
(
numfiles
,
tmp
.
Ncols
());
outMsize
(
"tmp"
,
tmp
);
outMsize
(
"tmpT"
,
tmpT
);
outMsize
(
"tmp"
,
tmp
);
outMsize
(
"tmpS"
,
tmpS
);
outMsize
(
"tmpT"
,
tmpT
);
outMsize
(
"tmpS"
,
tmpS
);
dbgmsg
(
string
(
" approach "
)
<<
opts
.
approach
.
value
()
<<
endl
);
dbgmsg
(
string
(
" approach "
)
<<
opts
.
approach
.
value
()
<<
endl
);
if
(
opts
.
approach
.
value
()
==
string
(
"tica"
)){
message
(
"Calculating T- and S-modes "
<<
endl
);
if
(
opts
.
approach
.
value
()
==
string
(
"tica"
)){
explained_var
=
krfact
(
tmp
,
tmpT
,
tmpS
);
message
(
"Calculating T- and S-modes "
<<
endl
);
Tmodes
.
clear
();
Smodes
.
clear
();
explained_var
=
krfact
(
tmp
,
tmpT
,
tmpS
);
for
(
int
ctr
=
1
;
ctr
<=
tmp
.
Ncols
();
ctr
++
){
Tmodes
.
clear
();
Smodes
.
clear
();
tmpT3
<<
reshape
(
tmp
.
Column
(
ctr
),
tmpT
.
Nrows
(),
numfiles
);
for
(
int
ctr
=
1
;
ctr
<=
tmp
.
Ncols
();
ctr
++
){
outMsize
(
"tmpT3"
,
tmpT3
);
tmpT3
<<
reshape
(
tmp
.
Column
(
ctr
),
tmpT
.
Nrows
(),
numfiles
);
tmpT2
<<
tmpT
.
Column
(
ctr
);
outMsize
(
"tmpT3"
,
tmpT3
);
tmpS2
<<
tmpS
.
Column
(
ctr
);
tmpT2
<<
tmpT
.
Column
(
ctr
);
tmpT3
<<
SP
(
tmpT3
,
pow
(
ones
(
tmpT3
.
Nrows
(),
1
)
*
tmpS2
.
t
(),
-
1
));
tmpS2
<<
tmpS
.
Column
(
ctr
);
if
(
numfiles
>
1
)
tmpT3
<<
SP
(
tmpT3
,
pow
(
ones
(
tmpT3
.
Nrows
(),
1
)
*
tmpS2
.
t
(),
-
1
));
tmpT2
|=
tmpT3
;
if
(
numfiles
>
1
)
if
(
mean
(
tmpS2
,
1
).
AsScalar
()
<
0
){
tmpT2
|=
tmpT3
;
tmpT2
*=-
1.0
;
if
(
mean
(
tmpS2
,
1
).
AsScalar
()
<
0
){
tmpS2
*=-
1.0
;
tmpT2
*=-
1.0
;
}
tmpS2
*=-
1.0
;
add_Tmodes
(
tmpT2
);
add_Smodes
(
tmpS2
);
}
}
}
add_Tmodes
(
tmpT2
);
else
{
add_Smodes
(
tmpS2
);
Tmodes
.
clear
();
}
Smodes
.
clear
();
}
for
(
int
ctr
=
1
;
ctr
<=
tmp
.
Ncols
();
ctr
++
){
else
{
tmpT3
<<
tmp
.
Column
(
ctr
);
Tmodes
.
clear
();
add_Tmodes
(
tmpT3
);
Smodes
.
clear
();
}
for
(
int
ctr
=
1
;
ctr
<=
tmp
.
Ncols
();
ctr
++
){
tmpT3
<<
tmp
.
Column
(
ctr
);
add_Tmodes
(
tmpT3
);
}
}
}
if
(
opts
.
approach
.
value
()
!=
string
(
"concat"
)){
if
(
opts
.
approach
.
value
()
!=
string
(
"concat"
)){
//add GLM OLS fit
//add GLM OLS fit
dbgmsg
(
string
(
" GLM fitting "
)
<<
endl
);
dbgmsg
(
string
(
" GLM fitting "
)
<<
endl
);
if
(
Tdes
.
Storage
()){
if
(
Tdes
.
Storage
()){
Matrix
alltcs
=
Tmodes
.
at
(
0
).
Column
(
1
);
Matrix
alltcs
=
Tmodes
.
at
(
0
).
Column
(
1
);
for
(
int
ctr
=
1
;
ctr
<
(
int
)
Tmodes
.
size
();
ctr
++
)
for
(
int
ctr
=
1
;
ctr
<
(
int
)
Tmodes
.
size
();
ctr
++
)
alltcs
|=
Tmodes
.
at
(
ctr
).
Column
(
1
);
alltcs
|=
Tmodes
.
at
(
ctr
).
Column
(
1
);
if
((
alltcs
.
Nrows
()
==
Tdes
.
Nrows
())
&&
(
Tdes
.
Nrows
()
>
Tdes
.
Ncols
()))
if
((
alltcs
.
Nrows
()
==
Tdes
.
Nrows
())
&&
(
Tdes
.
Nrows
()
>
Tdes
.
Ncols
()))
glmT
.
olsfit
(
alltcs
,
Tdes
,
Tcon
);
glmT
.
olsfit
(
alltcs
,
Tdes
,
Tcon
);
}
}
if
(
Sdes
.
Storage
()){
if
(
Sdes
.
Storage
()){
Matrix
alltcs
=
Smodes
.
at
(
0
);
Matrix
alltcs
=
Smodes
.
at
(
0
);
for
(
int
ctr
=
1
;
ctr
<
(
int
)
Smodes
.
size
();
ctr
++
)
for
(
int
ctr
=
1
;
ctr
<
(
int
)
Smodes
.
size
();
ctr
++
)
alltcs
|=
Smodes
.
at
(
ctr
);
alltcs
|=
Smodes
.
at
(
ctr
);
if
((
alltcs
.
Nrows
()
==
Sdes
.
Nrows
())
&&
(
Sdes
.
Nrows
()
>
Sdes
.
Ncols
()
&&
alltcs
.
Nrows
()
>
2
))
if
((
alltcs
.
Nrows
()
==
Sdes
.
Nrows
())
&&
(
Sdes
.
Nrows
()
>
Sdes
.
Ncols
()
&&
alltcs
.
Nrows
()
>
2
))
glmS
.
olsfit
(
alltcs
,
Sdes
,
Scon
);
glmS
.
olsfit
(
alltcs
,
Sdes
,
Scon
);
}
}
}
}
// else{
// else{
// dbgmsg(string(" Bypassing krfac ") << endl);
// dbgmsg(string(" Bypassing krfac ") << endl);
// add_Tmodes(tmp);
// add_Tmodes(tmp);
// add_Smodes(tmpS);
// add_Smodes(tmpS);
// }
// }
}
void
MelodicData
::
set_TSmode
()
{
dbgmsg
(
string
(
"START: set_TSmode"
));
if
(
opts
.
dr
.
value
())
dual_regression
();
else
set_TSmode_depr
();
dbgmsg
(
string
(
"END: set_TSmode"
));
dbgmsg
(
string
(
"END: set_TSmode"
));
}
}
...
@@ -393,8 +400,15 @@ namespace Melodic{
...
@@ -393,8 +400,15 @@ namespace Melodic{
void
MelodicData
::
setup_migp
()
void
MelodicData
::
setup_migp
()
{
{
dbgmsg
(
"starting MIGP"
);
dbgmsg
(
"starting MIGP"
);
//permute input vector if desired std::random_shuffle ( opts.inputfname.value().begin(), opts.inputfname.value().end() );
std
::
vector
<
int
>
myctr
;
for
(
int
i
=
0
;
i
<
numfiles
;
++
i
)
myctr
.
push_back
(
i
);
if
(
opts
.
migp_shuffle
.
value
()){
message
(
"Randomising input file order"
<<
endl
);
std
::
random_shuffle
(
myctr
.
begin
(),
myctr
.
end
()
);
}
Matrix
tmpData
;
Matrix
tmpData
;
bool
tmpvarnorm
=
opts
.
varnorm
.
value
();
bool
tmpvarnorm
=
opts
.
varnorm
.
value
();
...
@@ -403,7 +417,11 @@ namespace Melodic{
...
@@ -403,7 +417,11 @@ namespace Melodic{
}
}
for
(
int
ctr
=
0
;
ctr
<
numfiles
;
ctr
++
){
for
(
int
ctr
=
0
;
ctr
<
numfiles
;
ctr
++
){
tmpData
=
process_file
(
opts
.
inputfname
.
value
().
at
(
ctr
),
numfiles
)
/
numfiles
;
tmpData
=
process_file
(
opts
.
inputfname
.
value
().
at
(
myctr
.
at
(
ctr
)),
numfiles
)
/
numfiles
;
if
(
opts
.
migpN
.
value
()
==
0
){
opts
.
migpN
.
set_T
(
2
*
tmpData
.
Nrows
()
-
1
);
}
if
(
opts
.
debug
.
value
())
if
(
opts
.
debug
.
value
())
save4D
(
tmpData
,
string
(
"preproc_dat"
)
+
num2str
(
ctr
+
1
));
save4D
(
tmpData
,
string
(
"preproc_dat"
)
+
num2str
(
ctr
+
1
));
...
@@ -412,6 +430,7 @@ namespace Melodic{
...
@@ -412,6 +430,7 @@ namespace Melodic{
else
else
Data
&=
tmpData
;
Data
&=
tmpData
;
outMsize
(
"Data"
,
Data
);
//reduce dim down to manageable level
//reduce dim down to manageable level
if
(
Data
.
Nrows
()
>
opts
.
migpN
.
value
()){
if
(
Data
.
Nrows
()
>
opts
.
migpN
.
value
()){
message
(
" Reducing data matrix to a "
<<
opt
.
migpN
.
value
()
<<
" dimensional subspace "
<<
endl
);
message
(
" Reducing data matrix to a "
<<
opt
.
migpN
.
value
()
<<
" dimensional subspace "
<<
endl
);
...
@@ -421,6 +440,8 @@ namespace Melodic{
...
@@ -421,6 +440,8 @@ namespace Melodic{
pcaE
=
pcaE
.
Columns
(
pcaE
.
Ncols
()
-
opts
.
migpN
.
value
()
+
1
,
pcaE
.
Ncols
());
pcaE
=
pcaE
.
Columns
(
pcaE
.
Ncols
()
-
opts
.
migpN
.
value
()
+
1
,
pcaE
.
Ncols
());
Data
=
pcaE
.
t
()
*
Data
;
Data
=
pcaE
.
t
()
*
Data
;
}
}
outMsize
(
"Data"
,
Data
);
}
}
//update mask
//update mask
...
@@ -1059,7 +1080,7 @@ namespace Melodic{
...
@@ -1059,7 +1080,7 @@ namespace Melodic{
unmixMatrix
=
pinv
(
mixMatrix
);
unmixMatrix
=
pinv
(
mixMatrix
);
}
}
void
MelodicData
::
re
regress
()
void
MelodicData
::
dual_
regress
ion
()
{
{
if
((
numfiles
>
1
)){
if
((
numfiles
>
1
)){
...
...
This diff is collapsed.
Click to expand it.
meldata.h
+
2
−
1
View file @
52c7ffce
...
@@ -103,6 +103,7 @@ namespace Melodic{
...
@@ -103,6 +103,7 @@ namespace Melodic{
}
}
}
}
void
set_TSmode_depr
();
void
set_TSmode
();
void
set_TSmode
();
inline
Matrix
&
get_param
()
{
return
param
;}
inline
Matrix
&
get_param
()
{
return
param
;}
...
@@ -206,7 +207,7 @@ namespace Melodic{
...
@@ -206,7 +207,7 @@ namespace Melodic{
}
}
void
sort
();
void
sort
();
void
re
regress
();
void
dual_
regress
ion
();
vector
<
Matrix
>
DWM
,
WM
;
vector
<
Matrix
>
DWM
,
WM
;
basicGLM
glmT
,
glmS
;
basicGLM
glmT
,
glmS
;
...
...
This diff is collapsed.
Click to expand it.
meloptions.h
+
13
−
3
View file @
52c7ffce
...
@@ -56,6 +56,8 @@ class MelodicOptions {
...
@@ -56,6 +56,8 @@ class MelodicOptions {
Option
<
bool
>
dr_pca
;
Option
<
bool
>
dr_pca
;
Option
<
bool
>
migp
;
Option
<
bool
>
migp
;
Option
<
int
>
migpN
;
Option
<
int
>
migpN
;
Option
<
bool
>
migp_shuffle
;
Option
<
bool
>
dr
;
Option
<
float
>
vn_level
;
Option
<
float
>
vn_level
;
Option
<
int
>
numICs
;
Option
<
int
>
numICs
;
Option
<
string
>
approach
;
Option
<
string
>
approach
;
...
@@ -199,9 +201,15 @@ class MelodicOptions {
...
@@ -199,9 +201,15 @@ class MelodicOptions {
migp
(
string
(
"--migp"
),
false
,
migp
(
string
(
"--migp"
),
false
,
string
(
"switch on MIGP data reduction"
),
string
(
"switch on MIGP data reduction"
),
false
,
no_argument
,
false
),
false
,
no_argument
,
false
),
migpN
(
string
(
"--migpN"
),
1000
,
migpN
(
string
(
"--migpN"
),
0
,
string
(
"Number of internal Eigenmaps"
),
string
(
"Number of internal Eigenmaps"
),
false
,
requires_argument
,
false
),
false
,
requires_argument
,
false
),
migp_shuffle
(
string
(
"--migp_order"
),
true
,
string
(
"Randomise MIGP file order (default: TRUE)"
),
false
,
no_argument
,
false
),
dr
(
string
(
"--dr"
),
false
,
string
(
"Dual Regression (default: TRUE)"
),
false
,
no_argument
,
false
),
vn_level
(
string
(
"--vn_level"
),
float
(
2.3
),
vn_level
(
string
(
"--vn_level"
),
float
(
2.3
),
string
(
"variance nomalisation threshold level (Z> value is ignored)"
),
string
(
"variance nomalisation threshold level (Z> value is ignored)"
),
false
,
requires_argument
,
false
),
false
,
requires_argument
,
false
),
...
@@ -408,6 +416,8 @@ class MelodicOptions {
...
@@ -408,6 +416,8 @@ class MelodicOptions {
options
.
add
(
dr_pca
);
options
.
add
(
dr_pca
);
options
.
add
(
migp
);
options
.
add
(
migp
);
options
.
add
(
migpN
);
options
.
add
(
migpN
);
options
.
add
(
migp_shuffle
);
options
.
add
(
dr
);
options
.
add
(
vn_level
);
options
.
add
(
vn_level
);
options
.
add
(
numICs
);
options
.
add
(
numICs
);
options
.
add
(
approach
);
options
.
add
(
approach
);
...
...
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