Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
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
Model 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 JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chenhao Ma
core
Commits
430f321d
Commit
430f321d
authored
8 years ago
by
Megan Henning
Browse files
Options
Downloads
Patches
Plain Diff
Add mapping and acquisition indexing
parent
65c6abbf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/dicom_doctype.py
+58
-31
58 additions, 31 deletions
bin/dicom_doctype.py
with
58 additions
and
31 deletions
bin/dicom_doctype.py
+
58
−
31
View file @
430f321d
...
...
@@ -10,6 +10,7 @@ import logging
from
api
import
config
es
=
config
.
es
db
=
config
.
db
DICOM_INDEX
=
'
dicom_store
'
...
...
@@ -19,59 +20,77 @@ def datetime(str_datetime):
def
age
(
str_age
):
pass
SKIPPED
=
[
'
PixelSpacing
'
,
'
ImageOrientationPatient
'
,
'
PatientAge
'
,
'
ImagePositionPatient
'
]
# TODO: Choose integer/long and float/double where appropriate
VR_TYPES
=
{
'
AE
'
:
str
,
'
AS
'
:
age
,
'
AT
'
:
int
,
'
CS
'
:
str
,
'
DA
'
:
datetime
,
'
DS
'
:
float
,
'
DT
'
:
datetime
,
'
FD
'
:
float
,
'
FL
'
:
float
,
'
IS
'
:
int
,
'
LO
'
:
str
,
'
LT
'
:
str
,
'
AE
'
:
[
'
str
ing
'
,
str
]
,
'
AS
'
:
[
'
long
'
,
int
]
,
'
AT
'
:
[
'
long
'
,
int
]
,
'
CS
'
:
[
'
str
ing
'
,
str
]
,
'
DA
'
:
[
'
date
'
,
datetime
]
,
'
DS
'
:
[
'
float
'
,
float
]
,
'
DT
'
:
[
'
date
'
,
datetime
]
,
'
FD
'
:
[
'
float
'
,
float
]
,
'
FL
'
:
[
'
float
'
,
float
]
,
'
IS
'
:
[
'
long
'
,
int
]
,
'
LO
'
:
[
'
str
ing
'
,
str
]
,
'
LT
'
:
[
'
str
ing
'
,
str
]
,
'
NONE
'
:
None
,
'
OB
'
:
None
,
'
OB or OW
'
:
None
,
'
OF
'
:
None
,
'
OW
'
:
None
,
'
PN
'
:
str
,
'
SH
'
:
str
,
'
SL
'
:
int
,
'
PN
'
:
[
'
str
ing
'
,
str
]
,
'
SH
'
:
[
'
str
ing
'
,
str
]
,
'
SL
'
:
[
'
long
'
,
int
]
,
'
SQ
'
:
None
,
'
SS
'
:
int
,
'
ST
'
:
str
,
'
TM
'
:
datetime
,
'
UI
'
:
str
,
'
UL
'
:
int
,
'
US
'
:
int
,
'
US or OW
'
:
int
,
'
US or SS
'
:
int
,
'
US or SS or OW
'
:
int
,
'
UT
'
:
str
,
'
SS
'
:
[
'
long
'
,
int
]
,
'
ST
'
:
[
'
str
ing
'
,
str
]
,
'
TM
'
:
[
'
date
'
,
datetime
]
,
'
UI
'
:
[
'
str
ing
'
,
str
]
,
'
UL
'
:
[
'
long
'
,
int
]
,
'
US
'
:
[
'
long
'
,
int
]
,
'
US or OW
'
:
[
'
long
'
,
int
]
,
'
US or SS
'
:
[
'
long
'
,
int
]
,
'
US or SS or OW
'
:
[
'
long
'
,
int
]
,
'
UT
'
:
[
'
str
ing
'
,
str
]
}
if
__name__
==
'
__main__
'
:
def
create_mappings
():
public_dict
=
dicom
.
_dicom_dict
.
DicomDictionary
field_mappings
=
{}
for
k
,
v
in
public_dict
.
iteritems
():
vr_type
=
v
[
0
]
field_name
=
v
[
4
]
vr_mapping
=
VR_TYPES
.
get
(
vr_type
)
if
vr_mapping
:
field_mappings
[
field_name
]
=
{
'
type
'
:
vr_mapping
[
0
]}
else
:
pass
#logging.warn('Skipping field {} of VR type {}'.format(field_name, vr_type))
return
field_mappings
#public_dict = dicom._dicom_dict.DicomDictionary
if
__name__
==
'
__main__
'
:
if
es
.
indices
.
exists
(
DICOM_INDEX
):
print
'
Removing existing dicom_store index...
'
res
=
es
.
indices
.
delete
(
index
=
DICOM_INDEX
)
print
'
response: {}
'
.
format
(
res
)
mappings
=
create_mappings
()
request
=
{
'
settings
'
:
{
'
number_of_shards
'
:
1
,
'
number_of_replicas
'
:
0
},
'
mappings
'
:
{
'
properties
'
:
{
'
title
'
:
{
'
type
'
:
'
string
'
}
'
dicom
'
:
{
'
properties
'
:
mappings
}
}
}
...
...
@@ -80,3 +99,11 @@ if __name__ == '__main__':
res
=
es
.
indices
.
create
(
index
=
DICOM_INDEX
,
body
=
request
)
print
'
response: {}
'
.
format
(
res
)
acquisitions
=
db
.
acquisitions
.
find
({
'
files.type
'
:
'
dicom
'
})
for
a
in
acquisitions
:
dicom_data
=
a
.
get
(
'
metadata
'
)
if
dicom_data
:
for
s
in
SKIPPED
:
dicom_data
.
pop
(
s
,
None
)
es
.
index
(
index
=
DICOM_INDEX
,
doc_type
=
'
dicom
'
,
body
=
dicom_data
)
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