Example #1
0
ExamenParams*
ParserDicom::getInfos(DIR* dir, string dirName)
{
    struct dirent* file = getOneFile(dir);
    if (file == NULL) {
        return NULL;
    }
    string fullpath = dirName + PATH_SEPARATOR + file->d_name;
    DcmFileFormat dcm;
    OFCondition cond = dcm.loadFile(fullpath.c_str());
    if (cond.bad()) {
        return NULL;
    }

    Information* generalInfos = new Information();
    OFString s;
    dcm.getDataset()->findAndGetOFString(DCM_PatientName, s);
    generalInfos->addInformation("Patient name", s.c_str());
    dcm.getDataset()->findAndGetOFString(DCM_PatientID, s);
    generalInfos->addInformation("Patient ID", s.c_str());
    dcm.getDataset()->findAndGetOFString(DCM_PatientBirthDate, s);
    generalInfos->addInformation("Patient birthday", s.c_str());
    dcm.getDataset()->findAndGetOFString(DCM_PatientAge, s);
    generalInfos->addInformation("Patient age", s.c_str());
    dcm.getDataset()->findAndGetOFString(DCM_PatientSex, s);
    generalInfos->addInformation("Patient sex", s.c_str());
    dcm.getDataset()->findAndGetOFString(DCM_PatientSize, s);
    generalInfos->addInformation("Patient size", s.c_str());
    dcm.getDataset()->findAndGetOFString(DCM_PatientWeight, s);
    generalInfos->addInformation("Patient weight", s.c_str());

    dcm.getDataset()->findAndGetOFString(DCM_ImagePositionPatient, s);
    generalInfos->addInformation("Image position patient", s.c_str());
    dcm.getDataset()->findAndGetOFString(DCM_ImageOrientationPatient, s);
    generalInfos->addInformation("Image orientation patient", s.c_str());

    dcm.getDataset()->findAndGetOFString(DCM_StudyID, s);
    generalInfos->addInformation("Study data", s.c_str());
    dcm.getDataset()->findAndGetOFString(DCM_StudyDate, s);
    generalInfos->addInformation("Study date", s.c_str());
    dcm.getDataset()->findAndGetOFString(DCM_StudyTime, s);
    generalInfos->addInformation("Study time", s.c_str());
    dcm.getDataset()->findAndGetOFString(DCM_StudyDescription, s);
    generalInfos->addInformation("Study description", s.c_str());

    dcm.getDataset()->findAndGetOFString(DCM_BitsAllocated, s);
    generalInfos->addInformation("Bits allocated", s.c_str());

    dcm.getDataset()->findAndGetOFString(DCM_BitsStored, s);
    generalInfos->addInformation("Bits stored", s.c_str());

    dcm.getDataset()->findAndGetOFString(DCM_HighBit, s);
    generalInfos->addInformation("High bit", s.c_str());

    generalInfos->addInformation("Intercept", s.c_str());
    dcm.getDataset()->findAndGetOFString(DCM_RescaleIntercept, s);
    int intercept = atoi(s.c_str());
    generalInfos->addInformation("Slope", s.c_str());
    dcm.getDataset()->findAndGetOFString(DCM_RescaleSlope, s);

    int slope = atoi(s.c_str());
    dcm.getDataset()->findAndGetOFString(DCM_WindowCenter, s);
    generalInfos->addInformation("Window center", s.c_str());
    int Wcenter=atoi(s.c_str());
    dcm.getDataset()->findAndGetOFString(DCM_WindowWidth, s);
    generalInfos->addInformation("Window width", s.c_str());
    int Wwidth=atoi(s.c_str());

    dcm.getDataset()->findAndGetOFString(DCM_SliceThickness, s);
    generalInfos->addInformation("Slice thickness", s.c_str());
    float Sthickness = atof(s.c_str());

    dcm.getDataset()->findAndGetOFString(DCM_WindowCenterWidthExplanation, s);
    generalInfos->addInformation("WindowCenterWidthExplanation", s.c_str());

    dcm.getDataset()->findAndGetOFString(DCM_Manufacturer, s);
    generalInfos->addInformation("Manufacturer", s.c_str());

    //---------------------------------------------
    // Affectation des parametres de l'examen
    //---------------------------------------------
    GrayTranslationFunction gtf(slope, intercept);
    ExamenParams* params = new ExamenParams(gtf, fullpath, generalInfos);

    params->getGrayViewWindow().setLuminosity(Wcenter);
    params->getGrayViewWindow().setContrast(Wwidth);
    //params->getGrayViewWindow().setMin(HundsfieldValue::min()); // Must choose !
    //params->getGrayViewWindow().setMax(HundsfieldValue::max());
    //params->setParametersSI(Sthickness);

    //---------------------------------------------
    // Examen size informations
    //---------------------------------------------
    DiDocument* didoc = new DiDocument(fullpath.c_str());
    DiMono2Image* dimg = new DiMono2Image(didoc, EIS_Normal);

    params->width = dimg->getColumns();
    params->height = dimg->getRows();
    params->depth = nbFiles(dir);

    params->resolutionX = dimg->getPixelWidth();;
    params->resolutionY = dimg->getPixelHeight();;
    params->resolutionZ = Sthickness; // check

    ostringstream sNbSlice, sSize, sResX, sResY;
    sResX << params->resolutionX;
    sResY << params->resolutionY;
    sNbSlice << params->depth + 1;
    sSize << params->width << " " << params->height;

    generalInfos->addInformation("Slice number", sNbSlice.str());
    generalInfos->addInformation("Scan resolution (x, y)", sSize.str());
    generalInfos->addInformation("Pixel resolution X", sResX.str());
    generalInfos->addInformation("Pixel resolution Y", sResY.str());

    delete dimg;
    delete didoc;

    return params;
}