コード例 #1
0
void SImageCenter::updating()
{

    ::fwData::Image::csptr image = this->getInput< ::fwData::Image >(s_IMAGE_IN);
    ::fwData::mt::ObjectReadLock imLock(image);

    SLM_ASSERT("Missing image '"+ s_IMAGE_IN + "'", image);

    const bool imageValidity = ::fwDataTools::fieldHelper::MedicalImageHelpers::checkImageValidity(image);

    if(!imageValidity)
    {
        SLM_WARN("Can not compute center of a invalid image.");
        return;
    }

    ::fwData::TransformationMatrix3D::sptr matrix =
        this->getInOut< ::fwData::TransformationMatrix3D >(s_TRANSFORM_INOUT);

    SLM_ASSERT("Missing matrix '"+ s_TRANSFORM_INOUT +"'", matrix);

    ::fwData::mt::ObjectWriteLock matLock(matrix);

    ::fwDataTools::TransformationMatrix3D::identity(matrix);

    //compute the center
    const ::fwData::Image::SizeType size       = image->getSize();
    const ::fwData::Image::SpacingType spacing = image->getSpacing();
    const ::fwData::Image::OriginType origin   = image->getOrigin();

    SLM_ASSERT("Image should be in 3 Dimensions", size.size() == 3);

    std::vector<double> center(3, 0.);

    center[0] = (static_cast<double>(size[0]) * spacing[0]) / 2.;
    center[1] = (static_cast<double>(size[1]) * spacing[1]) / 2.;
    center[2] = (static_cast<double>(size[2]) * spacing[2]) / 2.;

    //compute origin -center

    center[0] += origin[0];
    center[1] += origin[1];
    center[2] += origin[2];

    matrix->setCoefficient(0, 3, center[0]);
    matrix->setCoefficient(1, 3, center[1]);
    matrix->setCoefficient(2, 3, center[2]);

    // output the translation matrix

    auto sig = matrix->signal< ::fwData::TransformationMatrix3D::ModifiedSignalType >
                   (::fwData::TransformationMatrix3D::s_MODIFIED_SIG);

    sig->asyncEmit();

    m_sigComputed->asyncEmit();
}
コード例 #2
0
void SSliceIndexDicomPullerEditor::displayErrorMessage(const std::string& message) const
{
    SLM_WARN("Error: " + message);
    ::fwGui::dialog::MessageDialog messageBox;
    messageBox.setTitle("Error");
    messageBox.setMessage( message );
    messageBox.setIcon(::fwGui::dialog::IMessageDialog::CRITICAL);
    messageBox.addButton(::fwGui::dialog::IMessageDialog::OK);
    messageBox.show();
}
コード例 #3
0
void SStringReader::updating()
{
    SLM_TRACE_FUNC();

    if ( this->hasLocationDefined() )
    {
        // Read data.txt
        std::string line;
        std::string data("");
        std::ifstream myfile( this->getFile().string().c_str() );
        if ( myfile.is_open() )
        {
            while ( myfile.good() )
            {
                getline( myfile, line );
                OSLM_DEBUG("Read line : " << line );
                data += line;
            }
            myfile.close();
        }
        else
        {
            OSLM_ERROR("Unable to open file : " << this->getFile() );
        }
        OSLM_DEBUG("Loaded data : " << data );

        // Set new string value in your associated object
        auto myAssociatedData = this->getInOut< ::fwData::String >("targetString");
        SLM_ASSERT("Data not found", myAssociatedData);

        myAssociatedData->setValue( data );
    }
    else
    {
        SLM_WARN("Be careful, reader failed because no file location is defined." );
    }

    // Then, notifies listeners that the image has been modified
    this->notifyMessage();
}
コード例 #4
0
bool IActionSrv::confirmAction()
{
    bool actionIsConfirmed = true;

    if (m_confirmAction)
    {
        ::fwGui::dialog::MessageDialog dialog;
        dialog.setTitle("Confirmation");
        std::stringstream ss;
        ss << "Do you really want to execute this action ? ";
        if (!m_confirmMessage.empty())
        {
            ss << std::endl << m_confirmMessage;
        }
        dialog.setMessage( ss.str() );

        if(m_defaultButton == "yes")
        {
            dialog.setDefaultButton( ::fwGui::dialog::IMessageDialog::YES );
        }
        else if(m_defaultButton == "no")
        {
            dialog.setDefaultButton( ::fwGui::dialog::IMessageDialog::NO );
        }
        else if(!m_defaultButton.empty())
        {
            SLM_WARN("unknown button: " + m_defaultButton);
        }

        dialog.setIcon( ::fwGui::dialog::IMessageDialog::QUESTION );
        dialog.addButton( ::fwGui::dialog::IMessageDialog::YES_NO );
        ::fwGui::dialog::IMessageDialog::Buttons button = dialog.show();

        actionIsConfirmed = (button == ::fwGui::dialog::IMessageDialog::YES);
    }

    return actionIsConfirmed;
}
コード例 #5
0
::fwData::Object::sptr DataConverter::fromIgtlMessage(const ::igtl::MessageBase::Pointer src) const
{
    ::fwData::Object::sptr obj;
    const std::string deviceType = src->GetDeviceType();

    if (deviceType == "ATOMS")
    {
        obj = m_defaultConverter->fromIgtlMessage(src);
        return obj;
    }

    for(const converter::IConverter::sptr& converter : m_converters)
    {
        if (converter->getIgtlType() == deviceType)
        {
            obj = converter->fromIgtlMessage(src);
            return obj;
        }
    }

    SLM_WARN("Message type not supported : " + std::string(src->GetDeviceType()));
    return obj;
}
コード例 #6
0
void IFrameLayoutManager::defaultCloseCallback()
{
    SLM_WARN("No specific close callback defined");
}
コード例 #7
0
ファイル: SQueryEditor.cpp プロジェクト: fw4spl-org/fw4spl
void SQueryEditor::queryStudyDate()
{
    if(!m_serverHostnameKey.empty())
    {
        const std::string hostname = ::fwPreferences::getPreference(m_serverHostnameKey);
        if(!hostname.empty())
        {
            m_serverHostname = hostname;
        }
    }
    if(!m_serverPortKey.empty())
    {
        const std::string port = ::fwPreferences::getPreference(m_serverPortKey);
        if(!port.empty())
        {
            m_serverPort = std::stoi(port);
        }
    }

    try
    {
        // Vector of all Series that will be retrieved.
        ::fwMedData::SeriesDB::ContainerType allSeries;

        // Find Studies according to their StudyDate
        QJsonObject query;
        const std::string& beginDate = m_beginStudyDateEdit->date().toString("yyyyMMdd").toStdString();
        const std::string& endDate   = m_endStudyDateEdit->date().toString("yyyyMMdd").toStdString();
        const std::string& dateRange = beginDate + "-" + endDate;
        query.insert("StudyDate", dateRange.c_str());

        QJsonObject body;
        body.insert("Level", "Studies");
        body.insert("Query", query);
        body.insert("Limit", 0);

        /// Url PACS
        const std::string pacsServer("http://" + m_serverHostname + ":" + std::to_string(m_serverPort));

        /// Orthanc "/tools/find" route. POST a JSON to get all Studies corresponding to StudyDate range.
        ::fwNetworkIO::http::Request::sptr request = ::fwNetworkIO::http::Request::New(pacsServer + "/tools/find");
        QByteArray studiesListAnswer;
        try
        {
            studiesListAnswer = m_clientQt.post(request, QJsonDocument(body).toJson());
        }
        catch  (::fwNetworkIO::exceptions::HostNotFound& exception)
        {
            std::stringstream ss;
            ss << "Host not found:\n"
               << " Please check your configuration: \n"
               << "Pacs host name: " << m_serverHostname << "\n"
               << "Pacs port: " << m_serverPort << "\n";

            this->displayErrorMessage(ss.str());
            SLM_WARN(exception.what());
        }
        QJsonDocument jsonResponse         = QJsonDocument::fromJson(studiesListAnswer);
        const QJsonArray& studiesListArray = jsonResponse.array();
        const int studiesListArraySize     = studiesListArray.count();

        for(int i = 0; i < studiesListArraySize; ++i)
        {
            const std::string& studiesUID = studiesListArray.at(i).toString().toStdString();
            const std::string studiesUrl(pacsServer + "/studies/" + studiesUID);
            const QByteArray& studiesAnswer = m_clientQt.get( ::fwNetworkIO::http::Request::New(studiesUrl));

            jsonResponse = QJsonDocument::fromJson(studiesAnswer);
            const QJsonObject& jsonObj    = jsonResponse.object();
            const QJsonArray& seriesArray = jsonObj["Series"].toArray();
            const int seriesArraySize     = seriesArray.count();

            for(int i = 0; i < seriesArraySize; ++i)
            {
                const std::string& seriesUID = seriesArray.at(i).toString().toStdString();
                const std::string instancesUrl(pacsServer + "/series/" + seriesUID);
                const QByteArray& instancesAnswer = m_clientQt.get( ::fwNetworkIO::http::Request::New(instancesUrl));
                jsonResponse = QJsonDocument::fromJson(instancesAnswer);
                const QJsonObject& jsonObj      = jsonResponse.object();
                const QJsonArray& instanceArray = jsonObj["Instances"].toArray();

                // Retrieve the first instance for the needed information
                const std::string& instanceUID = instanceArray.at(0).toString().toStdString();
                const std::string instanceUrl(pacsServer + "/instances/" + instanceUID + "/simplified-tags");
                const QByteArray& instance = m_clientQt.get( ::fwNetworkIO::http::Request::New(instanceUrl));

                QJsonObject seriesJson = QJsonDocument::fromJson(instance).object();
                seriesJson.insert( "NumberOfSeriesRelatedInstances", instanceArray.count() );

                // Convert response to DicomSeries
                ::fwMedData::SeriesDB::ContainerType series = ::fwNetworkIO::helper::Series::toFwMedData(seriesJson);

                allSeries.insert(std::end(allSeries), std::begin(series), std::end(series));
                this->updateSeriesDB(allSeries);
            }
        }
    }
    catch (::fwNetworkIO::exceptions::Base& exception)
    {
        std::stringstream ss;
        ss << "Unknown error.";
        this->displayErrorMessage(ss.str());
        SLM_WARN(exception.what());
    }
}
コード例 #8
0
void SSliceIndexDicomPullerEditor::pullInstance()
{
    SLM_ASSERT("Pacs not configured.", m_pacsConfiguration);

    if( m_pacsConfiguration )
    {
        // Catch any errors
        try
        {
            // DicomSeries
            ::fwMedData::DicomSeries::sptr dicomSeries = this->getInOut< ::fwMedData::DicomSeries >("series");
            SLM_ASSERT("DicomSeries should not be null !", dicomSeries);

            // Get selected slice
            std::size_t selectedSliceIndex = m_sliceIndexSlider->value() + dicomSeries->getFirstInstanceNumber();

            m_seriesEnquirer->initialize(m_pacsConfiguration->getLocalApplicationTitle(),
                                         m_pacsConfiguration->getPacsHostName(),
                                         m_pacsConfiguration->getPacsApplicationPort(),
                                         m_pacsConfiguration->getPacsApplicationTitle(),
                                         m_pacsConfiguration->getMoveApplicationTitle());

            m_seriesEnquirer->connect();
            std::string seriesInstanceUID = dicomSeries->getInstanceUID();
            std::string sopInstanceUID    =
                m_seriesEnquirer->findSOPInstanceUID(seriesInstanceUID, static_cast<unsigned int>(selectedSliceIndex));

            // Check if an instance with the selected Instance Number is found on the PACS
            if(!sopInstanceUID.empty())
            {
                // Pull Selected Series using C-GET Requests
                m_seriesEnquirer->pullInstanceUsingGetRetrieveMethod(seriesInstanceUID, sopInstanceUID);

                // Add path and trigger reading
                ::boost::filesystem::path path     = ::fwTools::System::getTemporaryFolder() / "dicom/";
                ::boost::filesystem::path filePath = path.string() + seriesInstanceUID + "/" + sopInstanceUID;
                dicomSeries->addDicomPath(selectedSliceIndex, filePath);
                //m_slotReadImage->asyncRun(selectedSliceIndex);
                this->readImage(selectedSliceIndex);
            }
            else
            {
                std::stringstream ss;
                ss << "The selected series does not have an instance matching the selected instance number (" <<
                    selectedSliceIndex << ").";
                m_slotDisplayMessage->asyncRun(ss.str());
            }

            // Close connection
            m_seriesEnquirer->disconnect();

        }
        catch (::fwPacsIO::exceptions::Base& exception)
        {
            std::stringstream ss;
            ss << "Unable to connect to the pacs. Please check your configuration: \n"
               << "Pacs host name: " << m_pacsConfiguration->getPacsHostName() << "\n"
               << "Pacs application title: " << m_pacsConfiguration->getPacsApplicationTitle() << "\n"
               << "Pacs port: " << m_pacsConfiguration->getPacsApplicationPort() << "\n";
            m_slotDisplayMessage->asyncRun(ss.str());
            SLM_WARN(exception.what());
        }

    }
    else
    {
        SLM_ERROR("Pacs pull aborted : no pacs configuration found.");
    }
}
コード例 #9
0
ファイル: Logger.cpp プロジェクト: fw4spl-org/fw4spl
void Logger::warning(const std::string& message)
{
    ::fwLog::Log log(::fwLog::Log::WARNING, message);
    m_logContainer.push_back(log);
    SLM_WARN(message);
}
コード例 #10
0
RuntimeException::RuntimeException(const std::string& message) throw()
: ::fwCore::Exception(message)
{
    SLM_WARN( this->what() );
}
コード例 #11
0
RuntimeException::RuntimeException(const RuntimeException& exception) throw()
: ::fwCore::Exception(std::string(exception.what()))
{
    SLM_WARN( this->what() );
}
コード例 #12
0
ファイル: SeriesDBReader.cpp プロジェクト: fw4spl-org/fw4spl
void SeriesDBReader::addSeries( const ::fwMedData::SeriesDB::sptr& seriesDB,
                                const std::vector< std::string >& filenames)
{
    //gdcm::Trace::SetDebug( 1 );
    //gdcm::Trace::SetWarning( 1 );
    //gdcm::Trace::SetError( 1 );

    ::gdcm::Scanner scanner;
    const ::gdcm::Tag seriesUIDTag(0x0020, 0x000e);
    const ::gdcm::Tag seriesDateTag(0x0008, 0x0021);
    const ::gdcm::Tag seriesTimeTag(0x0008, 0x0031);
    const ::gdcm::Tag seriesTypeTag(0x0008, 0x0060);
    const ::gdcm::Tag seriesDescriptionTag(0x0008, 0x103e);
    const ::gdcm::Tag seriesPhysicianNamesTag(0x0008, 0x1050);

    const ::gdcm::Tag equipmentInstitutionNameTag(0x0008, 0x0080);

    const ::gdcm::Tag patientNameTag(0x0010, 0x0010);
    const ::gdcm::Tag patientIDTag(0x0010, 0x0020);
    const ::gdcm::Tag patientBirthdateTag(0x0010, 0x0030);
    const ::gdcm::Tag patientSexTag(0x0010, 0x0040);
    const ::gdcm::Tag studyUIDTag(0x0020, 0x000d);
    const ::gdcm::Tag studyDateTag(0x0008, 0x0020);
    const ::gdcm::Tag studyTimeTag(0x0008, 0x0030);
    const ::gdcm::Tag studyReferingPhysicianNameTag(0x0008, 0x0090);
    const ::gdcm::Tag studyDescriptionTag(0x0008, 0x1030);
    const ::gdcm::Tag studyPatientAgeTag(0x0010, 0x1010);

    const ::gdcm::Tag imageTypeTag(0x0008, 0x0008);
    const ::gdcm::Tag acquisitionDateTag(0x0008, 0x0022);
    const ::gdcm::Tag acquisitionTimeTag(0x0008, 0x0032);

    scanner.AddTag( seriesUIDTag );
    scanner.AddTag( seriesDateTag );
    scanner.AddTag( seriesTimeTag );
    scanner.AddTag( seriesTypeTag );
    scanner.AddTag( seriesDescriptionTag );
    scanner.AddTag( seriesPhysicianNamesTag );
    scanner.AddTag( equipmentInstitutionNameTag );
    scanner.AddTag( studyUIDTag );
    scanner.AddTag( patientNameTag );
    scanner.AddTag( patientIDTag );
    scanner.AddTag( patientBirthdateTag );
    scanner.AddTag( patientSexTag );
    scanner.AddTag( studyUIDTag );
    scanner.AddTag( studyDateTag );
    scanner.AddTag( studyTimeTag );
    scanner.AddTag( studyReferingPhysicianNameTag );
    scanner.AddTag( studyDescriptionTag );
    scanner.AddTag( studyPatientAgeTag );
    scanner.AddTag( imageTypeTag );
    scanner.AddTag( acquisitionDateTag );
    scanner.AddTag( acquisitionTimeTag );

    try
    {
        const bool isScanned = scanner.Scan( filenames );
        if( !isScanned )
        {
            SLM_ERROR("Scanner failed");
            return;
        }
        const ::gdcm::Directory::FilenamesType keys = scanner.GetKeys();

        typedef std::map< std::string, std::vector< std::string > > MapSeriesType;
        MapSeriesType mapSeries;

        for(const std::string& filename : keys)
        {
            SLM_ASSERT("'"+filename+"' is not a key in the mapping table", scanner.IsKey(filename.c_str()));

            const char* seriesUID = scanner.GetValue( filename.c_str(), seriesUIDTag );
            const char* acqDate   = scanner.GetValue( filename.c_str(), acquisitionDateTag );

            if (seriesUID)
            {
                std::string fileSetId = seriesUID;

                if (acqDate)
                {
                    fileSetId += "_";
                    fileSetId += acqDate;
                }

                const char* imageType = scanner.GetValue(filename.c_str(), imageTypeTag);
                if(imageType)
                {
                    // Treatment of secondary capture dicom file.
                    SLM_TRACE("Image Type : " + std::string(imageType));
                    fileSetId += "_";
                    fileSetId += imageType;
                }
                mapSeries[fileSetId].push_back(filename);
            }
            else
            {
                SLM_ERROR("No series name found in : " + filename );
            }
        }

        for(const auto& elt : mapSeries)
        {
            ::fwMedData::ImageSeries::sptr series  = ::fwMedData::ImageSeries::New();
            ::fwMedData::Patient::sptr patient     = series->getPatient();
            ::fwMedData::Study::sptr study         = series->getStudy();
            ::fwMedData::Equipment::sptr equipment = series->getEquipment();

            seriesDB->getContainer().push_back(series);

            SLM_TRACE( "Processing: '" + elt.first + "' file set.");
            const MapSeriesType::mapped_type& files = elt.second;
            if ( !files.empty() )
            {
                vtkSmartPointer< vtkStringArray > fileArray  = vtkSmartPointer< vtkStringArray >::New();
                vtkSmartPointer< vtkGDCMImageReader > reader = vtkSmartPointer< vtkGDCMImageReader >::New();
                reader->FileLowerLeftOn();

                ::gdcm::IPPSorter ippSorter;
                ippSorter.SetComputeZSpacing( true );
                ippSorter.SetZSpacingTolerance( 1e-3 );
                bool isSorted = ippSorter.Sort( files );

                std::vector<std::string> sorted;
                double zspacing = 0.;
                if(isSorted)
                {
                    sorted   = ippSorter.GetFilenames();
                    zspacing = ippSorter.GetZSpacing();
                    OSLM_TRACE("Found z-spacing:" << ippSorter.GetZSpacing());
                }
                else
                {
                    //  Else an error has been encountered.
                    //  We fall back to a more trivial sorting based on the InstanceNumber DICOM tag.
                    SLM_WARN("IPP Sorting failed. Falling back to Instance Number sorting.");
                    ::gdcm::Sorter sorter;
                    sorter.SetSortFunction(sortByInstanceNumber);
                    isSorted = sorter.StableSort( filenames);
                    if(isSorted)
                    {
                        // If the custom sorted returns true, it worked
                        // and the filenames are sorted by InstanceNumber (ASC).
                        sorted = sorter.GetFilenames();
                    }
                    else
                    {
                        // There is nothing more we can do to sort DICOM files.
                        SLM_ERROR("Failed to sort '"+elt.first+"'");
                    }
                }

                fileArray->Initialize();
                if(isSorted)
                {
                    SLM_TRACE("Success to sort '" + elt.first+"'");
                    if (!zspacing && sorted.size() > 1)
                    {
                        SLM_TRACE( "Guessing zspacing ..." );
                        if (!sorted.empty())
                        {
                            ::gdcm::Reader localReader1;
                            ::gdcm::Reader localReader2;
                            const std::string& f1 = *(sorted.begin());
                            const std::string& f2 = *(sorted.begin() + 1);
                            SLM_TRACE( "Search spacing in: '" + f1 +"'");
                            SLM_TRACE( "Search spacing in: '" + f2 +"'");

                            localReader1.SetFileName( f1.c_str() );
                            localReader2.SetFileName( f2.c_str() );
                            const bool canRead = localReader1.Read() && localReader2.Read();
                            if(canRead)
                            {
                                const std::vector<double> vOrigin1 =
                                    ::gdcm::ImageHelper::GetOriginValue(localReader1.GetFile());
                                const std::vector<double> vOrigin2 =
                                    ::gdcm::ImageHelper::GetOriginValue(localReader2.GetFile());
                                zspacing = vOrigin2[2] - vOrigin1[2];
                                OSLM_TRACE(
                                    "Found z-spacing:" << zspacing << " from : << " << vOrigin2[2] << " | " <<
                                    vOrigin1[2]);
                            }
                            SLM_ERROR_IF("Cannot read: '" + f1 + "' or: '" + f2 +"'", !canRead);
                        }
                    }
                }

                for(const std::string& file : sorted)
                {
                    SLM_TRACE("Add '" + file + "' to vtkGdcmReader");
                    fileArray->InsertNextValue(file.c_str());
                }

                ::fwData::Image::sptr pDataImage = ::fwData::Image::New();
                bool res = false;
                if (fileArray->GetNumberOfValues() > 0)
                {
                    reader->SetFileNames( fileArray );
                    try
                    {
                        SLM_TRACE("Read Series: '" + elt.first + "'");

                        //add progress observation
                        vtkSmartPointer< ::fwVtkIO::helper::vtkLambdaCommand > progressCallback =
                            vtkSmartPointer< ::fwVtkIO::helper::vtkLambdaCommand >::New();
                        progressCallback->SetCallback([this](vtkObject* caller, long unsigned int, void* )
                            {
                                auto filter = static_cast<vtkGDCMImageReader*>(caller);
                                m_job->doneWork( filter->GetProgress()*100 );
                            });
                        reader->AddObserver(vtkCommand::ProgressEvent, progressCallback);

                        m_job->addSimpleCancelHook( [&]()
                            {
                                reader->AbortExecuteOn();
                            } );

                        reader->Update();
                        reader->UpdateInformation();
                        reader->PropagateUpdateExtent();
                        try
                        {
                            ::fwVtkIO::fromVTKImage(reader->GetOutput(), pDataImage);
                            res = true;
                        }
                        catch(std::exception& e)
                        {
                            OSLM_ERROR("VTKImage to fwData::Image failed : "<<e.what());
                        }
                    }
                    catch (std::exception& e)
                    {
                        OSLM_ERROR( "Error during conversion : " << e.what() );
                    }
                    catch (...)
                    {
                        SLM_ERROR( "Unexpected error during conversion" );
                    }
                    m_job->finish();
                }

                if (res)
                {

                    SLM_ASSERT("No file to read", !files.empty());

                    // Read medical info
                    vtkMedicalImageProperties* medprop = reader->GetMedicalImageProperties();

                    const std::string patientName      = medprop->GetPatientName(); //"0010|0010"
                    const std::string patientId        = medprop->GetPatientID();
                    const std::string patientBirthdate = medprop->GetPatientBirthDate(); //"0010|0030"
                    const std::string patientSex       = medprop->GetPatientSex(); //"0010|0040"

                    const ::gdcm::Scanner::ValuesType gdcmPhysicianNames = scanner.GetValues( seriesPhysicianNamesTag );

                    const char* seriesUIDStr  = scanner.GetValue( files[0].c_str(), seriesUIDTag );
                    const char* seriesTimeStr = scanner.GetValue( files[0].c_str(), seriesTimeTag );
                    const char* seriesDateStr = scanner.GetValue( files[0].c_str(), seriesDateTag );

                    const std::string seriesModality    = medprop->GetModality(); //"0008|0060"
                    const std::string seriesDescription = medprop->GetSeriesDescription();
                    const std::string seriesDate        = ( seriesDateStr ? seriesDateStr : "" );
                    const std::string seriesTime        = ( seriesTimeStr ? seriesTimeStr : "" );

                    ::fwMedData::DicomValuesType seriesPhysicianNames;
                    for(const std::string& name :  gdcmPhysicianNames)
                    {
                        ::fwMedData::DicomValuesType result;
                        ::boost::split( result, name, ::boost::is_any_of("\\"));
                        seriesPhysicianNames.reserve(seriesPhysicianNames.size() + result.size());
                        seriesPhysicianNames.insert(seriesPhysicianNames.end(), result.begin(), result.end());
                    }

                    const char* studyUIDStr                   = scanner.GetValue( files[0].c_str(), studyUIDTag );
                    const char* studyReferingPhysicianNameStr =
                        scanner.GetValue( files[0].c_str(), studyReferingPhysicianNameTag );

                    const std::string studyDate             = medprop->GetStudyDate();
                    const std::string studyTime             = medprop->GetStudyTime();
                    const std::string studyDescription      = medprop->GetStudyDescription();  //"0008|1030"
                    const std::string studyPatientAge       = medprop->GetPatientAge();
                    const std::string equipementInstitution = medprop->GetInstitutionName(); //"0008|0080"

                    const std::string studyReferingPhysicianName =
                        ( studyReferingPhysicianNameStr ? studyReferingPhysicianNameStr : "" );

                    const double thickness = medprop->GetSliceThicknessAsDouble();//"0018|0050"
                    double center          = 0.0;
                    double width           = 0.0;
                    if (medprop->GetNumberOfWindowLevelPresets())//FIXME : Multiple preset !!!
                    {
                        medprop->GetNthWindowLevelPreset(0, &width, &center); //0028|1050,1051
                    }

                    // Image must have 3 dimensions
                    if(pDataImage->getNumberOfDimensions() == 2)
                    {
                        ::fwData::Image::SizeType imgSize = pDataImage->getSize();
                        imgSize.resize(3);
                        imgSize[2] = 1;
                        pDataImage->setSize(imgSize);

                        ::fwData::Image::OriginType imgOrigin = pDataImage->getOrigin();
                        imgOrigin.resize(3);
                        imgOrigin[2] = 0.;
                        pDataImage->setOrigin(imgOrigin);
                    }

                    ::fwData::Image::SpacingType vPixelSpacing = pDataImage->getSpacing();
                    vPixelSpacing.resize(3);
                    // assume z-spacing = 1 if not guessed
                    vPixelSpacing[2] = zspacing ? zspacing : (thickness ? thickness : 1.);
                    pDataImage->setSpacing(vPixelSpacing);
                    pDataImage->setWindowCenter(center);
                    pDataImage->setWindowWidth(width);

                    // Get the series instance UID.
                    SLM_ASSERT("No series UID", seriesUIDStr);
                    series->setInstanceUID(( seriesUIDStr ? seriesUIDStr : "UNKNOWN-UID" ));
                    series->setModality( seriesModality );
                    series->setDescription( seriesDescription );
                    series->setDate( seriesDate );
                    series->setTime( seriesTime );
                    series->setPerformingPhysiciansName( seriesPhysicianNames );
                    series->setImage(pDataImage);

                    SLM_ASSERT("No study UID",  studyUIDStr);
                    study->setInstanceUID(( studyUIDStr ? studyUIDStr : "UNKNOWN-UID" ));
                    study->setDate(studyDate);
                    study->setTime(studyTime);
                    study->setDescription(studyDescription);
                    study->setPatientAge(studyPatientAge);
                    study->setReferringPhysicianName(studyReferingPhysicianName);

                    patient->setName(patientName);
                    patient->setPatientId(patientId);
                    patient->setBirthdate(patientBirthdate);
                    patient->setSex(patientSex);

                    equipment->setInstitutionName(equipementInstitution);
                } // if res
            } // if !files.empty()
        }
    } // try
    catch (std::exception& e)
    {
        OSLM_ERROR( "Try with another reader or retry with this reader on a specific subfolder : " << e.what() );
        for(const auto filename : filenames)
        {
            SLM_ERROR("file error : " + filename );
        }
    }
}
コード例 #13
0
void ToolBarRegistrar::onItemAction()
{
    SLM_WARN("TODO: ToolBarRegistrar::onItemAction not yet implemented");
}