-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmethodist.sql
More file actions
45 lines (41 loc) · 2.42 KB
/
methodist.sql
File metadata and controls
45 lines (41 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
-- select * from series im where im.seriesDescription like "%lava%";
-- select * from series im where im.seriesDescription like "%vibe%";
-- select im.seriesTime,im.seriesDescription from series im where im.seriesDescription like "%vibe%";
.headers on
attach database ':memory:' as tmp;
create table tmp.flagdata as
select im.StudyInstanceUID,im.SeriesInstanceUID,im.seriesDescription,
CASE WHEN im.seriesDescription like "%vibe%" THEN 'vibe'
WHEN im.seriesDescription like "%Thr%" THEN 'thrive'
WHEN im.seriesDescription like "%lava%" THEN 'lava'
ELSE NULL END AS Vendor,
CASE WHEN (im.seriesDescription like 'DYN%VIBE' or im.seriesDescription like 'VIBE%DYN%' or im.seriesDescription like '3D_Thr_Pre' or im.seriesDescription like '%dynam%PRE%POST%' or im.seriesDescription like '%PRE%POST%dynam%' or im.seriesDescription like 'Ax%LAVA%PRE%POST' ) THEN 'Dyn'
WHEN (im.seriesDescription like 'AX%VIBE%10 MIN%%' or im.seriesDescription like 'AX%VIBE%DELAY%' or im.seriesDescription like '3D_Thr_Port' or im.seriesDescription like '%Ax%LAVA%DELAY%') THEN 'Pst'
ELSE NULL END AS ImageType from series im
where im.seriesDescription not like '%SUB%';
-- select * from tmp.flagdata where ImageType is not NULL;
-- select StudyInstanceUID,seriesDescription,Vendor,ImageType from tmp.flagdata where ImageType is not NULL;
create table tmp.widestudy as
select fg.StudyInstanceUID StudyInstanceUID,max(fg.Vendor) Vendor,
max(CASE WHEN ImageType = 'Dyn' THEN fg.SeriesInstanceUID ELSE NULL END) Dyn,
max(CASE WHEN ImageType = 'Pst' THEN fg.SeriesInstanceUID ELSE NULL END) Pst
from tmp.flagdata fg
where fg.ImageType is not null
GROUP BY fg.StudyInstanceUID;
-- select * from tmp.widestudy;
-- error check
select count(ws.StudyInstanceUID),count(ws.Dyn),count(ws.Pst) from tmp.widestudy ws;
-- wide format
-- cat methodist.sql | sqlite3 BerettaLab/ctkDICOM.sql
.mode csv
.output BerettaLab/wideformat.csv
select ws.*,dn.seriesDescription DynDescription , pt.seriesDescription PstDescription,
rtrim(di.Filename, replace(di.Filename, '/', '')) DynFilename,
rtrim(pi.Filename, replace(pi.Filename, '/', '')) PstFilename
from tmp.widestudy ws
join images di on di.SeriesInstanceUID= ws.Dyn
join images pi on pi.SeriesInstanceUID= ws.Pst
join tmp.flagdata dn on dn.SeriesInstanceUID= ws.Dyn
join tmp.flagdata pt on pt.SeriesInstanceUID= ws.Pst
GROUP BY ws.StudyInstanceUID;
.quit