File-sets
A file-set is a file, named DICOMDIR, that references a set of DICOM objects stored in files in the same file system directory or in subdirectories.
The structure of a file-set may be hierarchical. For instance it will list some patients, and for each patient, some studies concerning the patient, and for each study, image series acquired during the study, and for each series, the individual file containing images.
With DeCaMino, you can read a directory and traverse its content:
DicomReader reader = new DicomReader(); FileSet fs = new FileSet(new File("DICOMDIR"), reader); FileSet.Directory root = fs.getRootDirectory(); for (FileSet.Record rec : root) { System.out.println("Record found of type "+rec.getType()); File f = rec.getFile(); if (f != null) System.out.println("File referenced : "+f); FileSet.Directory sub = rec.getLowerLevelDirectory(); if (sub != null) System.out.println("Contains a subdirectory"); }
You can also write DICOMDIR. Here is an example adding all files found in file system directory images
in a DICOMDIR. A hierarchical structure from patients to images is automaticaly created by DeCaMino according to the data elements found in the files.
DicomReader reader = new DicomReader(); File dir = new File("images"); FileSet fs = new FileSet("TEST"); for (File f: dir.listFiles()) fs.add(f, reader); fs.write(dir);File names in DICOMDIR must exclusively be composed of uppercase letters, digits and
_
, and be no longer than 8 characters. So the files in images
may need to be renamed first.