-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdcmfile.cpp
More file actions
153 lines (120 loc) · 3.57 KB
/
dcmfile.cpp
File metadata and controls
153 lines (120 loc) · 3.57 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#include "dcmfile.h"
DcmFile::DcmFile()
{
}
DcmFile::~DcmFile()
{
}
int DcmFile::returnCountFiles()
{
return list.size();
}
void DcmFile::ReadInfoDcmFilePatient(QString &Patient)
{
OFString PatientOF;
if (DcmFilename.getDataset()->findAndGetOFString(DCM_PatientName,PatientOF).good())
{
Patient = PatientOF.data();
} else
Patient = "NONE";
}
void DcmFile::ReadInfoDcmFilePatientID(QString &PatientID)
{
OFString PatientIDOF;
if (DcmFilename.getDataset()->findAndGetOFString(DCM_PatientID, PatientIDOF).good())
{
PatientID = PatientIDOF.data();
} else
PatientID="NONE";
}
void DcmFile::ReadInfoDcmFilePatientAccess(QString &AccessionNumber)
{
OFString AccessionNumberOF;
if (DcmFilename.getDataset()->findAndGetOFString(DCM_AccessionNumber,AccessionNumberOF).good())
{
AccessionNumber = AccessionNumberOF.data();
} else
AccessionNumber="NONE" ;
}
void DcmFile::CreateQimageDcmFile()
{
DJDecoderRegistration::registerCodecs();
xfer = DcmFilename.getDataset()->getOriginalXfer();
m_dicomImage = new DicomImage(&DcmFilename,xfer,CIF_AcrNemaCompatibility,0,0);
s= new QSize(m_dicomImage->getWidth(),m_dicomImage->getHeight());
}
QImage DcmFile::ReadDicomData()
{
QImage m_qimage;
if(m_dicomImage->isMonochrome()){
m_qimage = QImage(m_dicomImage->getWidth(),m_dicomImage->getHeight(), QImage::Format_Indexed8);
}
m_dicomImage->setMinMaxWindow();
uchar *pixelData = (uchar *)(m_dicomImage->getOutputData(8 /* bits */));
for(unsigned y=0; y < m_dicomImage->getHeight(); y++)
{
uchar* scanLine = m_qimage.scanLine(y);
for(unsigned x = m_dicomImage->getWidth(); x != 0; --x)
{
*(scanLine++) = *(pixelData++);
}
}
DJDecoderRegistration::cleanup();
return m_qimage;
}
QSize DcmFile::sizeDCMFile()
{
}
void DcmFile::OpenDcmFile(int i)
{
result = DcmFilename.loadFile(list.at(i).absoluteFilePath().toLatin1().data());
if (result.bad())
return;
}
QList<QString> DcmFile::returnFiles()
{
QList<QString> files;
for (int i=0;i<list.size();i++){
files.append(list.at(i).absoluteFilePath().toLatin1().data());
}
return files;
}
void DcmFile::setURLpath(QString UrlPathDicom)
{
QDir Directory(UrlPathDicom);
Directory.setFilter(QDir::Files | QDir::NoDotAndDotDot |QDir::NoSymLinks);
list = Directory.entryInfoList();
}
QString DcmFile::returnTransferSyntax()
{
DcmXfer filexfer(DcmFilename.getDataset()->getOriginalXfer());
return filexfer.getXferID();
}
QString DcmFile::returnSopClass()
{
OFString SopClass;
DcmFilename.getDataset()->findAndGetOFString(DCM_SOPClassUID,SopClass);
return SopClass.data();
}
bool DcmFile::WriteDataToFile(QString UrlPathDicom,OFString Patient,OFString NumPatient,OFString AccesPatient)
{
result = DcmFilename.loadFile(UrlPathDicom.toLatin1().data());
if (result.bad())
return false;
result = DcmFilename.loadAllDataIntoMemory();
if (result.bad()) {
return false;
}
result= DcmFilename.getDataset()->putAndInsertString(DCM_PatientID,NumPatient.data());
if (result.bad())
return false;
result= DcmFilename.getDataset()->putAndInsertString(DCM_AccessionNumber,AccesPatient.data());
if (result.bad())
return false;
result= DcmFilename.getDataset()->putAndInsertString(DCM_PatientName,Patient.data());
if (result.bad())
return false;
result = DcmFilename.saveFile(UrlPathDicom.toLatin1().data());
if (result.bad())
return false;
}