Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MEG Metadata Importer
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Ben Wagner
MEG Metadata Importer
Commits
1da00c21
Commit
1da00c21
authored
1 year ago
by
Ben Wagner
Browse files
Options
Downloads
Patches
Plain Diff
Updates DOB (but is off by TimeZone) and Age
parent
ae508360
Branches
Branches containing commit
Tags
0.0.028
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Dockerfile
+1
-1
1 addition, 1 deletion
Dockerfile
manifest.json
+3
-3
3 additions, 3 deletions
manifest.json
run.py
+18
-9
18 additions, 9 deletions
run.py
with
22 additions
and
13 deletions
Dockerfile
+
1
−
1
View file @
1da00c21
...
...
@@ -4,7 +4,7 @@ FROM python:3.10-alpine
RUN
apk update
&&
apk add bash
RUN
pip
install
--no-cache-dir
--upgrade
pip
RUN
pip
install
--no-cache-dir
--extra-index-url
https://package_access_token:5pBy3bmcwmL-_Mwa4_T6@git.biohpc.swmed.edu/api/v4/projects/1606/packages/pypi/simple flywheel-gear-toolkit[sdk] fiffreader
RUN
pip
install
--no-cache-dir
--extra-index-url
https://package_access_token:5pBy3bmcwmL-_Mwa4_T6@git.biohpc.swmed.edu/api/v4/projects/1606/packages/pypi/simple flywheel-gear-toolkit[sdk] fiffreader
pytz
ENV
FLYWHEEL=/flywheel/v0
RUN
mkdir
-p
${
FLYWHEEL
}
...
...
This diff is collapsed.
Click to expand it.
manifest.json
+
3
−
3
View file @
1da00c21
...
...
@@ -16,7 +16,7 @@
},
"gear-builder"
:
{
"category"
:
"utility"
,
"image"
:
"ansir/meg-metadata-importer:0.0.0
13
"
"image"
:
"ansir/meg-metadata-importer:0.0.0
28
"
}
},
"description"
:
"Import file metadata into Flywheel. Metadata is stored under file.info.header. May also update blank fields in acquisition, session, and subject. Supports FIFF files."
,
...
...
@@ -28,7 +28,7 @@
"input-file"
:
{
"base"
:
"file"
,
"description"
:
"Input file."
,
"optional"
:
fals
e
,
"optional"
:
tru
e
,
"type"
:
{
"enum"
:
[
"fiff"
...
...
@@ -42,5 +42,5 @@
"name"
:
"meg-metadata-importer"
,
"source"
:
"https://git.biohpc.swmed.edu/ben.wagner/meg-metadata-importer"
,
"url"
:
"https://git.biohpc.swmed.edu/ben.wagner/meg-metadata-importer"
,
"version"
:
"0.0.0
13
"
"version"
:
"0.0.0
28
"
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
run.py
+
18
−
9
View file @
1da00c21
...
...
@@ -4,6 +4,7 @@ import logging
import
math
import
os
import
pprint
import
pytz
import
sys
from
flywheel_gear_toolkit
import
GearToolkitContext
...
...
@@ -117,19 +118,23 @@ def main(context):
if
session_id
:
session
=
context
.
client
.
get
(
session_id
)
if
not
session
.
age
and
meas_date
and
dob
:
if
(
not
session
.
age
or
session
.
age
==
0
)
and
meas_date
and
dob
:
age_delta
=
datetime
.
datetime
.
strptime
(
meas_date
,
"
%Y-%m-%d %H:%M:%S
"
)
-
datetime
.
datetime
.
strptime
(
dob
,
"
%Y-%m-%d
"
)
age
=
math
.
floor
(
age_delta
.
days
/
365.2425
)
print
(
f
"
Setting age to
{
age
}
"
)
session
.
update
(
age
=
age
)
age_years
=
math
.
floor
(
age_delta
.
days
/
365.2425
)
age_seconds
=
int
(
age_delta
.
total_seconds
())
print
(
f
"
Setting age to
{
age_years
}
(
{
age_seconds
}
seconds)
"
)
session
.
update
(
age
=
age_seconds
)
if
not
session
.
weight
and
weight
:
print
(
f
"
Setting weight to
{
weight
}
"
)
session
.
update
(
weight
=
weight
)
if
not
session
.
operator
and
experimenter
:
print
(
f
"
Setting operator to
{
experimenter
}
"
)
session
.
update
(
operator
=
experimenter
)
if
isinstance
(
experimenter
,
str
):
session
.
update
(
operator
=
experimenter
)
else
:
session
.
update
(
operator
=
set
(
experimenter
))
if
subject_id
:
subject
=
context
.
client
.
get
(
subject_id
)
...
...
@@ -139,15 +144,19 @@ def main(context):
if
not
subject
.
lastname
and
subj_last_name
:
print
(
f
"
Setting lastname to
{
subj_last_name
}
"
)
subject
.
update
(
lastname
=
subj_last_name
)
if
not
subject
.
sex
and
sex
:
if
(
not
subject
.
sex
or
subject
.
sex
==
"
unknown
"
)
and
sex
:
mfu
=
"
unknown
"
# not sure if 0 is male/female or something else...same for 1
if
sex
==
0
:
mfu
=
"
male
"
if
sex
==
1
:
mfu
=
"
male
"
if
sex
==
2
:
mfu
=
"
female
"
print
(
f
"
Setting sex to
{
mfu
}
"
)
subject
.
update
(
sex
=
mfu
)
if
(
not
subject
.
date_of_birth
)
and
dob
:
dt_dob
=
datetime
.
datetime
.
strptime
(
dob
,
"
%Y-%m-%d
"
)
dt_dob
=
dt_dob
.
replace
(
tzinfo
=
pytz
.
UTC
)
print
(
f
"
Setting DOB to
{
dt_dob
}
from
{
dob
}
"
)
subject
.
update
(
date_of_birth
=
dt_dob
)
# return sucessful exit code
return
0
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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