Message: DICOM example Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question DICOM example 

Forum: Medical Applications
Date: 12 Feb, 2014
From: Gaurav Singhal <Gaurav Singhal>

After deleting .g4dcm files in folder and then executing the DICOM example, this while loop in DicomHandler.cc is running infinite times.

line no. : 133

function : ReadFile(FILE* dicom, char* filename2)

while(true) {
    //Reading groups and elements :
    readGroupId = 0;
    readElementId = 0;
    // group ID
    rflag = std::fread(buffer, 2, 1, dicom);
    GetValue(buffer, readGroupId);
    // element ID
    rflag = std::fread(buffer, 2, 1, dicom);
    GetValue(buffer, readElementId);

    // Creating a tag to be identified afterward
    G4int tagDictionary = readGroupId*0x10000 + readElementId;

    // beginning of the pixels
    if(tagDictionary == 0x7FE00010) {
        // Folling 2 fread's are modifications to original DICOM example (Jonathan Madsen)
        rflag = std::fread(buffer,2,1,dicom);   // Reserved 2 bytes (not used for pixels)
        rflag = std::fread(buffer,4,1,dicom);   // Element Length   (not used for pixels)
        break;      // Exit to ReadImageData()
    }

    // VR or element length
    rflag = std::fread(buffer,2,1,dicom);
    GetValue(buffer, elementLength2);

    // If value representation (VR) is OB, OW, SQ, UN, added OF and UT
    //the next length is 32 bits
    if((elementLength2 == 0x424f ||     // "OB"
        elementLength2 == 0x574f ||     // "OW"
        elementLength2 == 0x464f ||     // "OF"
        elementLength2 == 0x5455 ||     // "UT"
        elementLength2 == 0x5153 ||     // "SQ"
        elementLength2 == 0x4e55) &&    // "UN"
       !fImplicitEndian ) {             // explicit VR

        rflag = std::fread(buffer, 2, 1, dicom); // Skip 2 reserved bytes

        // element length
        rflag = std::fread(buffer, 4, 1, dicom);
        GetValue(buffer, elementLength4);

        if(elementLength2 == 0x5153)
        {
            if(elementLength4 == 0xFFFFFFFF)
            {
                read_undefined_nested( dicom );
                elementLength4=0;
            }  else{
                if(read_defined_nested( dicom, elementLength4 )==0){
                    G4cerr << "Function read_defined_nested() failed!" << G4endl;
                    exit(-10);               }
            }
        } else  {
            // Reading the information with data
            rflag = std::fread(data, elementLength4,1,dicom);
        }

    }  else {

        //  explicit with VR different than previous ones
        if(!fImplicitEndian || readGroupId == 2) {

            //G4cout << "Reading  DICOM files with Explicit VR"<< G4endl;
            // element length (2 bytes)
            rflag = std::fread(buffer, 2, 1, dicom);
            GetValue(buffer, elementLength2);
            elementLength4 = elementLength2;

            rflag = std::fread(data, elementLength4, 1, dicom);

        } else {                                  // Implicit VR

            //G4cout << "Reading  DICOM files with Implicit VR"<< G4endl;

            // element length (4 bytes)
            if(std::fseek(dicom, -2, SEEK_CUR) != 0) {
                G4cerr << "[DicomHandler] fseek failed" << G4endl;
                exit(-10);}

            rflag = std::fread(buffer, 4, 1, dicom);
            GetValue(buffer, elementLength4);

            //G4cout <<  std::hex<< elementLength4 << G4endl;

            if(elementLength4 == 0xFFFFFFFF)
            {
                read_undefined_nested(dicom);
                elementLength4=0;
            }  else{
                rflag = std::fread(data, elementLength4, 1, dicom);
            }

        }
    }

    // NULL termination
    data[elementLength4] = '\0';

    // analyzing information
    GetInformation(tagDictionary, data);
}

Please tell me whats the issue. As this is an example that comes with geant4 toolkit, it should work fine.

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 Question: Re: DICOM example   (Pedro Arce - 18 Feb, 2014)
(_ None: Re: DICOM example   (Gaurav Singhal - 18 Feb, 2014)
(_ Question: Re: DICOM example   (Nicola - 09 Apr, 2014)
(_ Question: Re: DICOM example   (Ananta Raj Chalise - 11 Apr, 2017)
(_ Feedback: Re: DICOM example   (Pedro Arce - 11 Apr, 2017)
 Add Message Add Message
to: "DICOM example"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]