Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bidsme_examples
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository 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
Show more breadcrumbs
GIGA-CRC Human Imaging
Public
BIDStools
BIDSme
bidsme_examples
Commits
2552fe93
Commit
2552fe93
authored
5 years ago
by
Beliy Nikita
Browse files
Options
Downloads
Patches
Plain Diff
Adapetd to BidsSession
parent
664c374b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
example1/resources/plugins/definitions.py
+2
-2
2 additions, 2 deletions
example1/resources/plugins/definitions.py
example1/resources/plugins/rename_plugin.py
+21
-16
21 additions, 16 deletions
example1/resources/plugins/rename_plugin.py
with
23 additions
and
18 deletions
example1/resources/plugins/definitions.py
+
2
−
2
View file @
2552fe93
...
...
@@ -54,7 +54,7 @@ for ses in Series:
def
checkSeries
(
path
:
str
,
subject
:
str
,
session
:
str
,
critical
:
bool
)
->
None
:
critical
:
bool
)
->
bool
:
"""
Retrieve list of series from path and checks
its compatibility with defined list
...
...
@@ -74,7 +74,7 @@ def checkSeries(path: str,
if
session
not
in
Series
:
msg
=
"
{}/{}: Invalid session
"
.
format
(
subject
,
session
)
reportError
(
msg
,
critical
,
KeyError
)
return
return
False
passed
=
True
series
=
sorted
(
os
.
listdir
(
path
))
series
=
[
s
.
split
(
"
-
"
,
1
)[
1
]
for
s
in
series
]
...
...
This diff is collapsed.
Click to expand it.
example1/resources/plugins/rename_plugin.py
+
21
−
16
View file @
2552fe93
import
os
import
pandas
import
glob
import
logging
import
shutil
from
tools
import
tools
from
bidsMeta
import
BIDSfieldLibrary
from
bids
import
BidsSession
from
definitions
import
Series
,
checkSeries
...
...
@@ -36,6 +36,7 @@ excel_col_list = {'Patient' : 'pat',
sub_columns
=
BIDSfieldLibrary
()
def
InitEP
(
source
:
str
,
destination
:
str
,
dry
:
bool
,
subjects
:
str
=
""
)
->
int
:
...
...
@@ -71,8 +72,8 @@ def InitEP(source: str, destination: str,
|
df_subjects
[
'
cnt
'
].
notnull
()]
def
SubjectEP
(
session
)
:
sub_id
=
int
(
session
[
"
subject
"
]
)
def
SubjectEP
(
session
:
BidsSession
)
->
int
:
sub_id
=
int
(
session
.
subject
)
index
=
df_subjects
.
loc
[
df_subjects
[
"
pat
"
]
==
sub_id
].
index
status
=
0
prefix
=
"
pat
"
...
...
@@ -93,7 +94,7 @@ def SubjectEP(session):
age
=
int
(
line
[
1
])
education
=
int
(
line
[
2
])
values
=
sub_columns
.
GetTemplate
()
values
[
"
participant_id
"
]
=
"
sub-
"
+
session
[
"
subject
"
]
values
[
"
participant_id
"
]
=
"
sub-
"
+
session
.
subject
values
[
"
sex
"
]
=
sex
values
[
"
age
"
]
=
age
values
[
"
education
"
]
=
education
...
...
@@ -113,7 +114,7 @@ def SubjectEP(session):
scans_map
=
{}
scans_order
=
sorted
([
os
.
path
.
basename
(
s
)
for
s
in
tools
.
lsdirs
(
os
.
path
.
join
(
rawfolder
,
session
[
"
subject
"
]
),
session
.
subject
),
"
s*
"
)
])
for
ind
,
s
in
enumerate
((
"
_1
"
,
"
_2
"
,
"
_3
"
)):
...
...
@@ -161,27 +162,31 @@ def SubjectEP(session):
if
not
os
.
path
.
isfile
(
model_participants
):
sub_columns
.
DumpDefinitions
(
model_participants
)
session
[
"
subject
"
]
=
"
sub-
"
+
session
[
"
subject
"
]
session
.
subject
=
"
sub-
"
+
session
.
subject
return
0
def
SessionEP
(
session
)
:
def
SessionEP
(
session
:
BidsSession
)
->
int
:
# retrieving correct session name
session
[
"
session
"
]
=
scans_map
[
session
[
"
session
"
]
]
session
.
session
=
scans_map
[
session
.
session
]
return
0
def
SessionEndEP
(
session
):
res
=
checkSeries
(
os
.
path
.
join
(
session
[
"
out_path
"
],
"
MRI
"
),
session
[
"
subject
"
],
session
[
"
session
"
],
False
)
def
SessionEndEP
(
session
:
BidsSession
):
out_path
=
os
.
path
.
join
(
bidsfolder
,
session
.
getPath
(
True
),
"
MRI
"
)
if
not
checkSeries
(
out_path
,
session
.
subject
,
session
.
session
,
False
):
return
1
# parcing log files
if
session
[
"
session
"
]
==
"
ses-STROOP
"
:
if
session
.
session
==
"
ses-STROOP
"
:
return
0
logs
=
os
.
path
.
join
(
session
[
"
in_path
"
]
,
"
inp
"
)
aux_d
=
os
.
path
.
join
(
session
[
"
out_path
"
]
,
"
aux
"
)
logs
=
os
.
path
.
join
(
session
.
in_path
,
"
inp
"
)
aux_d
=
os
.
path
.
join
(
out_path
,
"
aux
"
)
if
not
os
.
path
.
isdir
(
logs
):
raise
NotADirectoryError
(
logs
)
...
...
@@ -197,5 +202,5 @@ def SessionEndEP(session):
if
not
os
.
path
.
isfile
(
file
):
raise
FileNotFoundError
(
file
)
shutil
.
copy2
(
file
,
aux_d
)
return
0
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