Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
telecom
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Roque
telecom
Commits
70a084bc
Commit
70a084bc
authored
Aug 03, 2018
by
Roque Porchetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_wendelin_telecom_ingestion: metadata for nifty images .nii
parent
3c85c817
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
10 deletions
+39
-10
bt5/erp5_wendelin_telecom_ingestion/ExtensionTemplateItem/portal_components/extension.erp5.external_process_raw_data.py
...al_components/extension.erp5.external_process_raw_data.py
+37
-10
bt5/erp5_wendelin_telecom_ingestion/ExtensionTemplateItem/portal_components/extension.erp5.external_process_raw_data.xml
...l_components/extension.erp5.external_process_raw_data.xml
+2
-0
No files found.
bt5/erp5_wendelin_telecom_ingestion/ExtensionTemplateItem/portal_components/extension.erp5.external_process_raw_data.py
View file @
70a084bc
...
...
@@ -115,7 +115,7 @@ def processTextData(file_name, data_array, data_descriptor):
try
:
json_report
=
getJSONfromTextFile
(
file_name
)
data_descriptor
.
setTextContent
(
json_report
)
log
(
"Data Descriptor content saved"
)
log
(
"Data Descriptor
text
content saved"
)
except
Exception
as
e
:
log
(
"Error handling Data Descriptor content: "
+
str
(
e
))
...
...
@@ -179,16 +179,43 @@ def processCsvData(file_name, data_array, data_descriptor, delimiter=","):
def
processTsvData
(
file_name
,
data_array
,
data_descriptor
):
processCsvData
(
file_name
,
data_array
,
data_descriptor
,
delimiter
=
"
\
t
"
)
def
processNiiData
(
file_name
,
data_array
,
data_descriptor
):
def
processNiiData
(
file_name
,
data_array
,
data_descriptor
,
gz
=
False
):
old_file
=
file_name
file_name
=
file_name
+
".nii.gz"
if
gz
else
file_name
+
".nii"
os
.
rename
(
old_file
,
file_name
)
try
:
import
nibabel
as
nib
img
=
nib
.
load
(
file_name
)
data
=
{}
data
[
"File content sample: "
]
=
"nifti files data processing not available yet."
for
key
in
img
.
header
:
try
:
if
type
(
img
.
header
[
key
])
is
np
.
ndarray
:
content
=
img
.
header
[
key
].
tolist
()
try
:
if
np
.
isnan
(
img
.
header
[
key
]):
content
=
"nan"
except
:
pass
else
:
content
=
img
.
header
[
key
]
if
content
==
0
:
content
=
"0"
json
.
dumps
(
content
)
if
content
!=
""
:
data
[
key
]
=
content
except
Exception
as
e
:
pass
# ignore non serializable info
json_data
=
json
.
dumps
(
data
)
data_descriptor
.
setTextContent
(
json_data
)
log
(
"Data Descriptor nii content saved"
)
except
Exception
as
e
:
log
(
"Error handling Data Descriptor nii content: "
+
str
(
e
))
raise
e
finally
:
os
.
rename
(
file_name
,
old_file
)
def
processGZData
(
file_name
,
data_array
,
data_descriptor
):
if
data_array
.
getReference
().
endswith
(
".nii/gz"
)
:
processNiiData
(
file_name
,
data_array
,
data_descriptor
)
e
lse
:
try
:
processNiiData
(
file_name
,
data_array
,
data_descriptor
,
gz
=
True
)
e
xcept
:
raise
KeyError
(
"gz"
)
def
processRawData
(
data_stream
,
data_array
,
data_descriptor
,
reference_extension
):
...
...
@@ -219,7 +246,7 @@ def processRawData(data_stream, data_array, data_descriptor, reference_extension
else
:
options
[
"default"
](
file_name
,
data_array
,
data_descriptor
)
except
KeyError
,
e
:
return
"Proccessing for
%s data
not implemented yet."
%
reference_extension
return
"Proccessing for
data in this %s
not implemented yet."
%
reference_extension
except
Exception
as
e
:
return
"Error while processing raw data: "
+
str
(
e
)
finally
:
...
...
bt5/erp5_wendelin_telecom_ingestion/ExtensionTemplateItem/portal_components/extension.erp5.external_process_raw_data.xml
View file @
70a084bc
...
...
@@ -55,6 +55,8 @@
<string>
W:100, 8: Unused variable \'times\' (unused-variable)
</string>
<string>
W:137, 6: No exception type(s) specified (bare-except)
</string>
<string>
W:173, 8: Unreachable code (unreachable)
</string>
<string>
W:192, 11: Using type() instead of isinstance() for a typecheck. (unidiomatic-typecheck)
</string>
<string>
W:196, 10: No exception type(s) specified (bare-except)
</string>
</tuple>
</value>
</item>
...
...
Write
Preview
Markdown
is supported
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