Skip to content

Instantly share code, notes, and snippets.

@JulesGorny
Last active March 22, 2021 08:59
Show Gist options
  • Select an option

  • Save JulesGorny/1cf5786ba23d65bfd7e6 to your computer and use it in GitHub Desktop.

Select an option

Save JulesGorny/1cf5786ba23d65bfd7e6 to your computer and use it in GitHub Desktop.

Revisions

  1. JulesGorny revised this gist Sep 19, 2014. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions DICOMDIR_Open.cpp
    Original file line number Diff line number Diff line change
    @@ -30,9 +30,8 @@ else
    //If a file is selected
    if(sName != "")
    {
    QString DICOM_file_fromDICOMDIR = sName;
    //Build the absolute path for DICOM file
    QString DICOM_file_path = DICOMDIR_folder + "/" + DICOM_file_fromDICOMDIR;
    //sName is the path for the file from the DICOMDIR file
    //You need to create the absolute path to use the DICOM file

    //Here you can do different tests (does the file exists ? for example)

  2. JulesGorny revised this gist Sep 19, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion DICOMDIR_Open.cpp
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    //Open the DICOMDIR File
    QString DICOMDIR_folder = "C:/Folder1/Folder2";
    char *fileName = "C:/Folder1/Folder2/DICOMDIR";
    const char *fileName = "C:/Folder1/Folder2/DICOMDIR";
    DcmDicomDir dicomdir(fileName);
    //Retrieve root node
    DcmDirectoryRecord *root = &dicomdir.getRootRecord();
  3. JulesGorny revised this gist Sep 19, 2014. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions DICOMDIR_Open.cpp
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    //Open the DICOMDIR File
    QString DICOMDIR_folder = "C:/Folder1/Folder2";
    char* fileName = "C:/Folder1/Folder2/DICOMDIR";
    char *fileName = "C:/Folder1/Folder2/DICOMDIR";
    DcmDicomDir dicomdir(fileName);
    //Retrieve root node
    DcmDirectoryRecord *root = &dicomdir.getRootRecord();
    @@ -9,7 +9,7 @@ DcmDirectoryRecord *rootTest = new DcmDirectoryRecord(*root);
    DcmDirectoryRecord *PatientRecord = NULL;
    DcmDirectoryRecord *StudyRecord = NULL;
    DcmDirectoryRecord *SeriesRecord = NULL;
    DcmDirectoryRecord* image = NULL;
    DcmDirectoryRecord *image = NULL;

    if(rootTest == NULL || rootTest->nextSub(PatientRecord) == NULL)
    std::cout << "It looks like the selected file does not have the expected format." << std::endl;
    @@ -23,7 +23,7 @@ else
    {
    while ((image = SeriesRecord->nextSub(image)) != NULL)
    {
    const char* sName;
    const char *sName;
    //Retrieve the file name
    image->findAndGetString(DCM_ReferencedFileID, sName);

  4. JulesGorny revised this gist Sep 19, 2014. 1 changed file with 10 additions and 2 deletions.
    12 changes: 10 additions & 2 deletions DICOMDIR_Open.cpp
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    //Open the DICOMDIR File
    DcmDicomDir dicomdir(fileName.toStdString().c_str());
    QString DICOMDIR_folder = "C:/Folder1/Folder2";
    char* fileName = "C:/Folder1/Folder2/DICOMDIR";
    DcmDicomDir dicomdir(fileName);
    //Retrieve root node
    DcmDirectoryRecord *root = &dicomdir.getRootRecord();
    //Prepare child elements
    @@ -28,7 +30,13 @@ else
    //If a file is selected
    if(sName != "")
    {

    QString DICOM_file_fromDICOMDIR = sName;
    //Build the absolute path for DICOM file
    QString DICOM_file_path = DICOMDIR_folder + "/" + DICOM_file_fromDICOMDIR;

    //Here you can do different tests (does the file exists ? for example)

    //Treat the dicom file
    }
    }
    }
  5. JulesGorny renamed this gist Sep 19, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  6. JulesGorny created this gist Sep 19, 2014.
    37 changes: 37 additions & 0 deletions DICOMDIR_Open
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    //Open the DICOMDIR File
    DcmDicomDir dicomdir(fileName.toStdString().c_str());
    //Retrieve root node
    DcmDirectoryRecord *root = &dicomdir.getRootRecord();
    //Prepare child elements
    DcmDirectoryRecord *rootTest = new DcmDirectoryRecord(*root);
    DcmDirectoryRecord *PatientRecord = NULL;
    DcmDirectoryRecord *StudyRecord = NULL;
    DcmDirectoryRecord *SeriesRecord = NULL;
    DcmDirectoryRecord* image = NULL;

    if(rootTest == NULL || rootTest->nextSub(PatientRecord) == NULL)
    std::cout << "It looks like the selected file does not have the expected format." << std::endl;
    else
    {
    while ((PatientRecord = root->nextSub(PatientRecord)) != NULL)
    {
    while ((StudyRecord = PatientRecord->nextSub(StudyRecord)) != NULL)
    {
    while ((SeriesRecord = StudyRecord->nextSub(SeriesRecord)) != NULL)
    {
    while ((image = SeriesRecord->nextSub(image)) != NULL)
    {
    const char* sName;
    //Retrieve the file name
    image->findAndGetString(DCM_ReferencedFileID, sName);

    //If a file is selected
    if(sName != "")
    {

    }
    }
    }
    }
    }
    }