Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
FSL
ukbparse
Commits
855c17d7
Commit
855c17d7
authored
May 07, 2019
by
Paul McCarthy
🚵
Browse files
ENH: New --description_file option to save column descriptions out to
file. Used in fmrib config
parent
83399fcb
Changes
3
Hide whitespace changes
Inline
Side-by-side
ukbparse/config.py
View file @
855c17d7
...
...
@@ -133,7 +133,8 @@ CLI_ARGUMENTS = collections.OrderedDict((
((
'etf'
,
'time_format'
),
{
'default'
:
'default'
}),
((
'nr'
,
'num_rows'
),
{
'type'
:
int
}),
((
'uf'
,
'unknown_vars_file'
),
{}),
((
'imf'
,
'icd10_map_file'
),
{})]),
((
'imf'
,
'icd10_map_file'
),
{}),
((
'def'
,
'description_file'
),
{})]),
(
'TSV export options'
,
[
((
'ts'
,
'tsv_sep'
),
{
'default'
:
DEFAULT_TSV_SEP
}),
...
...
@@ -363,6 +364,9 @@ CLI_ARGUMENT_HELP = {
'icd10_map_file'
:
'Save converted ICD10 code mappings to file'
,
'description_file'
:
'Save descriptions of each column to file'
,
# TSV export options
'tsv_sep'
:
'Column separator string to use in output file (default: "{}")'
.
format
(
...
...
ukbparse/configs/fmrib.cfg
View file @
855c17d7
...
...
@@ -7,6 +7,7 @@ log_file log.txt
unknown_vars_file unknowns.tsv
non_numeric_file non_numerics.tsv
icd10_map_file icd10_codes.tsv
description_file descriptions.tsv
plugin_file fmrib
loader FMRIB_internal_info.txt FMRIBImaging
date_format FMRIBImagingDate
...
...
ukbparse/main.py
View file @
855c17d7
...
...
@@ -7,15 +7,15 @@
"""This module contains the ``ukbparse`` entry point. """
import
multiprocessing
as
mp
import
sys
import
shutil
import
logging
import
fnmatch
import
tempfile
import
warnings
import
datetime
import
calendar
import
multiprocessing
as
mp
import
sys
import
shutil
import
logging
import
fnmatch
import
tempfile
import
warnings
import
datetime
import
calendar
import
ukbparse
import
ukbparse.util
as
util
...
...
@@ -115,6 +115,7 @@ def main(argv=None):
finaliseColumns
(
dtable
,
args
,
unknowns
,
unprocessed
)
doExport
(
dtable
,
args
)
doICD10Export
(
args
)
doDescriptionExport
(
dtable
,
args
)
finally
:
# shutdown the pool gracefully
...
...
@@ -410,6 +411,33 @@ def doICD10Export(args):
exc_info
=
True
)
def
doDescriptionExport
(
dtable
,
args
):
"""If a ``--description_file`` has been specified, a description for every
file is saved out to the file.
"""
if
args
.
description_file
is
None
:
return
with
util
.
timed
(
'Description export'
,
log
):
cols
=
dtable
.
allColumns
[
1
:]
vartable
=
dtable
.
vartable
try
:
with
open
(
args
.
description_file
,
'wt'
)
as
f
:
for
c
in
cols
:
desc
=
vartable
.
loc
[
c
.
vid
,
'Description'
]
if
desc
==
c
.
name
:
desc
=
'n/a'
f
.
write
(
'{}
\t
{}
\n
'
.
format
(
c
.
name
,
desc
))
except
Exception
as
e
:
log
.
warning
(
'Failed to export descriptions: {}'
.
format
(
e
),
exc_info
=
True
)
def
configLogging
(
args
):
"""Configures ``ukbparse`` logging.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment