Hi James,
Yes. I was trying to call using an IDL filepath string. The code for the addFile method is as follows:
public int addFile(File f) throws IOException {
int n = 0;
if (f.isDirectory()) {
File[] fs = f.listFiles();
for (int i = 0; i < fs.length; i++) {
n += addFile(fs[i]);
}
return n;
}
DicomInputStream in = new DicomInputStream(f);
in.setHandler(new StopTagInputHandler(Tag.PixelData));
DicomObject dcmobj = in.readDicomObject();
DicomObject patrec = ap.makePatientDirectoryRecord(dcmobj);
DicomObject styrec = ap.makeStudyDirectoryRecord(dcmobj);
DicomObject serrec = ap.makeSeriesDirectoryRecord(dcmobj);
DicomObject instrec =
ap.makeInstanceDirectoryRecord(dcmobj, dicomdir.toFileID(f));
DicomObject rec = writer().addPatientRecord(patrec);
if (rec == patrec) {
++n;
}
rec = writer().addStudyRecord(rec, styrec);
if (rec == styrec) {
++n;
}
rec = writer().addSeriesRecord(rec, serrec);
if (rec == serrec) {
++n;
}
if (n == 0 && checkDuplicate) {
String iuid = dcmobj.getString(Tag.MediaStorageSOPInstanceUID);
if (dicomdir.findInstanceRecord(rec, iuid) != null) {
System.out.print('D');
return 0;
}
}
writer().addChildRecord(rec, instrec);
System.out.print('.');
return n + 1;
}
I do not know if anyone here has used the dcm4che tool which is available on the website
www.dcm4che.org
All I am following is:
1. Take an image input from IDL.
2. Make an object of that using the java.util.File option.
3. Pass that object into the dicomdir java file which has an add file option.
It is a big chunk of file I know. But, if you or anyone can think of a shortcut way for me to pass an image into this file and then get a dicomdir out of it, It would be great!!!
Thank you
Rohit
|