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
e8a47df7
Commit
e8a47df7
authored
12 years ago
by
Christian Beckmann
Browse files
Options
Downloads
Patches
Plain Diff
GLM reporting / unequal length fix
parent
9ce78b6a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
meldata.cc
+56
-39
56 additions, 39 deletions
meldata.cc
meldata.h
+5
-2
5 additions, 2 deletions
meldata.h
with
61 additions
and
41 deletions
meldata.cc
+
56
−
39
View file @
e8a47df7
...
...
@@ -144,7 +144,7 @@ namespace Melodic{
tmp
=
expand_dimred
(
mixMatrix
);
tmpT
=
zeros
(
tmp
.
Nrows
()
/
numfiles
,
tmp
.
Ncols
());
tmpS
=
zero
s
(
numfiles
,
tmp
.
Ncols
());
tmpS
=
one
s
(
numfiles
,
tmp
.
Ncols
());
outMsize
(
"tmp"
,
tmp
);
outMsize
(
"tmpT"
,
tmpT
);
...
...
@@ -153,49 +153,60 @@ namespace Melodic{
dbgmsg
(
string
(
" approach "
)
<<
opts
.
approach
.
value
()
<<
endl
);
if
(
opts
.
approach
.
value
()
!=
string
(
"concat"
)){
message
(
"Calculating T- and S-modes "
<<
endl
);
explained_var
=
krfact
(
tmp
,
tmpT
,
tmpS
);
if
(
opts
.
approach
.
value
()
==
string
(
"tica"
)){
Tmodes
.
clear
();
Smodes
.
clear
();
for
(
int
ctr
=
1
;
ctr
<=
tmp
.
Ncols
();
ctr
++
){
tmpT3
<<
reshape
(
tmp
.
Column
(
ctr
),
tmpT
.
Nrows
(),
numfiles
);
outMsize
(
"tmpT3"
,
tmpT3
);
tmpT2
<<
tmpT
.
Column
(
ctr
);
tmpS2
<<
tmpS
.
Column
(
ctr
);
tmpT3
<<
SP
(
tmpT3
,
pow
(
ones
(
tmpT3
.
Nrows
(),
1
)
*
tmpS2
.
t
(),
-
1
));
if
(
numfiles
>
1
)
tmpT2
|=
tmpT3
;
if
(
mean
(
tmpS2
,
1
).
AsScalar
()
<
0
){
tmpT2
*=-
1.0
;
tmpS2
*=-
1.0
;
}
add_Tmodes
(
tmpT2
);
add_Smodes
(
tmpS2
);
message
(
"Calculating T- and S-modes "
<<
endl
);
explained_var
=
krfact
(
tmp
,
tmpT
,
tmpS
);
Tmodes
.
clear
();
Smodes
.
clear
();
for
(
int
ctr
=
1
;
ctr
<=
tmp
.
Ncols
();
ctr
++
){
tmpT3
<<
reshape
(
tmp
.
Column
(
ctr
),
tmpT
.
Nrows
(),
numfiles
);
outMsize
(
"tmpT3"
,
tmpT3
);
tmpT2
<<
tmpT
.
Column
(
ctr
);
tmpS2
<<
tmpS
.
Column
(
ctr
);
tmpT3
<<
SP
(
tmpT3
,
pow
(
ones
(
tmpT3
.
Nrows
(),
1
)
*
tmpS2
.
t
(),
-
1
));
if
(
numfiles
>
1
)
tmpT2
|=
tmpT3
;
if
(
mean
(
tmpS2
,
1
).
AsScalar
()
<
0
){
tmpT2
*=-
1.0
;
tmpS2
*=-
1.0
;
}
//add GLM OLS fit
if
(
Tdes
.
Storage
()){
Matrix
alltcs
=
Tmodes
.
at
(
0
).
Column
(
1
);
for
(
int
ctr
=
1
;
ctr
<
(
int
)
Tmodes
.
size
();
ctr
++
)
alltcs
|=
Tmodes
.
at
(
ctr
).
Column
(
1
);
if
((
alltcs
.
Nrows
()
==
Tdes
.
Nrows
())
&&
(
Tdes
.
Nrows
()
>
Tdes
.
Ncols
()))
glmT
.
olsfit
(
alltcs
,
Tdes
,
Tcon
);
}
if
(
Sdes
.
Storage
()){
Matrix
alltcs
=
Smodes
.
at
(
0
);
for
(
int
ctr
=
1
;
ctr
<
(
int
)
Smodes
.
size
();
ctr
++
)
alltcs
|=
Smodes
.
at
(
ctr
);
if
((
alltcs
.
Nrows
()
==
Sdes
.
Nrows
())
&&
(
Sdes
.
Nrows
()
>
Sdes
.
Ncols
()
&&
alltcs
.
Nrows
()
>
2
))
glmS
.
olsfit
(
alltcs
,
Sdes
,
Scon
);
add_Tmodes
(
tmpT2
);
add_Smodes
(
tmpS2
);
}
}
}
else
{
add_Tmodes
(
tmp
);
Tmodes
.
clear
();
Smodes
.
clear
();
for
(
int
ctr
=
1
;
ctr
<=
tmp
.
Ncols
();
ctr
++
){
tmpT3
<<
tmp
.
Column
(
ctr
);
add_Tmodes
(
tmpT3
);
}
}
if
(
opts
.
approach
.
value
()
!=
string
(
"concat"
)){
//add GLM OLS fit
dbgmsg
(
string
(
" GLM fitting "
)
<<
endl
);
if
(
Tdes
.
Storage
()){
Matrix
alltcs
=
Tmodes
.
at
(
0
).
Column
(
1
);
for
(
int
ctr
=
1
;
ctr
<
(
int
)
Tmodes
.
size
();
ctr
++
)
alltcs
|=
Tmodes
.
at
(
ctr
).
Column
(
1
);
if
((
alltcs
.
Nrows
()
==
Tdes
.
Nrows
())
&&
(
Tdes
.
Nrows
()
>
Tdes
.
Ncols
()))
glmT
.
olsfit
(
alltcs
,
Tdes
,
Tcon
);
}
if
(
Sdes
.
Storage
()){
Matrix
alltcs
=
Smodes
.
at
(
0
);
for
(
int
ctr
=
1
;
ctr
<
(
int
)
Smodes
.
size
();
ctr
++
)
alltcs
|=
Smodes
.
at
(
ctr
);
if
((
alltcs
.
Nrows
()
==
Sdes
.
Nrows
())
&&
(
Sdes
.
Nrows
()
>
Sdes
.
Ncols
()
&&
alltcs
.
Nrows
()
>
2
))
glmS
.
olsfit
(
alltcs
,
Sdes
,
Scon
);
}
}
// else{
// dbgmsg(string(" Bypassing krfac ") << endl);
// add_Tmodes(tmp);
// add_Smodes(tmpS);
// }
dbgmsg
(
string
(
"END: set_TSmode"
));
}
dbgmsg
(
string
(
"END: set_TSmode"
));
}
void
MelodicData
::
setup
()
...
...
@@ -233,6 +244,11 @@ namespace Melodic{
if
(
tmpData
.
Ncols
()
==
alldat
.
Ncols
()
&&
tmpData
.
Nrows
()
==
alldat
.
Nrows
())
alldat
+=
tmpData
;
else
{
if
(
opts
.
approach
.
value
()
==
string
(
"tica"
)){
cerr
<<
"ERROR:: data dimensions do not match, TICA not possible
\n\n
"
;
exit
(
2
);
}
if
(
tmpData
.
Ncols
()
==
alldat
.
Ncols
()){
int
mindim
=
min
(
alldat
.
Nrows
(),
tmpData
.
Nrows
());
alldat
=
alldat
.
Rows
(
1
,
mindim
);
...
...
@@ -511,6 +527,7 @@ namespace Melodic{
}
//Output T- & S-modes
save_Tmodes
();
save_Smodes
();
...
...
This diff is collapsed.
Click to expand it.
meldata.h
+
5
−
2
View file @
e8a47df7
...
...
@@ -90,8 +90,11 @@ namespace Melodic{
inline
void
save_Tmodes
(){
if
(
Tmodes
.
size
()
>
0
){
Matrix
tmp
=
Tmodes
.
at
(
0
);
for
(
unsigned
int
ctr
=
1
;
ctr
<
Tmodes
.
size
();
ctr
++
)
tmp
|=
Tmodes
.
at
(
ctr
);
outMsize
(
"tmp"
,
tmp
);
for
(
unsigned
int
ctr
=
1
;
ctr
<
Tmodes
.
size
();
ctr
++
){
outMsize
(
"Tmodes "
,
Tmodes
.
at
(
ctr
));
tmp
|=
Tmodes
.
at
(
ctr
);
}
saveascii
(
tmp
,
opts
.
outputfname
.
value
()
+
"_Tmodes"
);
}
}
...
...
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