protected override IEnumerable <fo.DicomDataset> DoFind ( fo.DicomDataset request, IQueryOptions options, string queryLevel, IEnumerable <IMatchingCondition> conditions ) { return(QueryDataAccess.Search(conditions, options, queryLevel)); }
public IMediaId Create ( fo.DicomDataset dataset, int frame, string mediaType, string transferSyntax ) { return(new DicomMediaId(dataset, frame, mediaType, transferSyntax)); }
protected override void Upload(fo.DicomDataset dicomObject, int frame, IStorageLocation storeLocation) { var frameIndex = frame - 1; DicomPixelData pd = DicomPixelData.Create(dicomObject); byte[] buffer = pd.GetFrame(frameIndex).Data; storeLocation.Upload(buffer); }
public IEnumerable <T> ProcessDataSet(fo.DicomDataset dataset) { BeginProcessingElements( ); foreach (var element in dataset) { ProcessElement(element); } return(EndProcessingElements()); }
public fo.DicomDataset Convert(string xmlDcm) { fo.DicomDataset ds = new fo.DicomDataset( ); XDocument document = XDocument.Parse(xmlDcm); ReadChildren(ds, document.Root, 0); fo.DicomFile df = new fo.DicomFile(ds); return(ds); }
private static void FillInstsanceLevel(fo.DicomDataset instanceDs) { instanceDs.Add <object>(fo.DicomTag.SpecificCharacterSet, null); instanceDs.Add <object>(fo.DicomTag.SOPClassUID, null); instanceDs.Add <object>(fo.DicomTag.SOPInstanceUID, null); instanceDs.Add <object>(fo.DicomTag.InstanceNumber, null); instanceDs.Add <object>(fo.DicomTag.Rows, null); instanceDs.Add <object>(fo.DicomTag.Columns, null); instanceDs.Add <object>(fo.DicomTag.BitsAllocated, null); instanceDs.Add <object>(fo.DicomTag.NumberOfFrames, null); }
private fo.DicomDataset GetReferencedInstsance(fo.DicomDataset ds) { var classUID = ds.Get <fo.DicomElement> (fo.DicomTag.SOPClassUID, null); var sopUID = ds.Get <fo.DicomElement> (fo.DicomTag.SOPInstanceUID, null); var dataset = new fo.DicomDataset( ); dataset.AddOrUpdate(classUID); dataset.AddOrUpdate(sopUID); return(dataset); }
protected virtual IEnumerable <DicomDataset> QueryInstances(IStudyId studyId) { Dicom.DicomDataset ds = new Dicom.DicomDataset(); ds.Add(Dicom.DicomTag.StudyInstanceUID, studyId.StudyInstanceUID); ds.Add(DicomTag.SeriesInstanceUID, ""); ds.Add(DicomTag.PatientID, ""); ds.Add(DicomTag.PatientName, ""); ds.Add(DicomTag.SeriesDescription, ""); ds.Add(DicomTag.SOPInstanceUID, ""); return(QueryService.FindObjectInstances(ds, GetQueryOptions(studyId))); }
protected override void Upload(fo.DicomDataset dicomDataset, int frame, IStorageLocation location) { fo.DicomFile df = new fo.DicomFile(dicomDataset); using (Stream stream = new MemoryStream()) { df.Save(stream); stream.Position = 0; location.Upload(stream); } }
private IEnumerable <DicomDataset> QueryInstances(string studyInstanceUid) { Dicom.DicomDataset ds = new Dicom.DicomDataset(); ds.Add(Dicom.DicomTag.StudyInstanceUID, studyInstanceUid); ds.Add(DicomTag.SeriesInstanceUID, ""); ds.Add(DicomTag.PatientID, ""); ds.Add(DicomTag.PatientName, ""); ds.Add(DicomTag.SeriesDescription, ""); ds.Add(DicomTag.SOPInstanceUID, ""); return(QueryService.FindObjectInstances(ds, new QueryOptions( ))); }
public ICollection <fo.DicomDataset> Find ( fo.DicomDataset request, IQueryOptions options, string queryLevel ) { IEnumerable <IMatchingCondition> conditions = null; conditions = BuildConditions(request); return(DoFind(request, options, queryLevel, conditions)); }
private static void FillSeriesLevel(fo.DicomDataset seriesDs) { seriesDs.Add <object>(fo.DicomTag.SpecificCharacterSet, null); seriesDs.Add <object>(fo.DicomTag.Modality, null); seriesDs.Add <object>(fo.DicomTag.TimezoneOffsetFromUTC, null); seriesDs.Add <object>(fo.DicomTag.SeriesDescription, null); seriesDs.Add <object>(fo.DicomTag.RetrieveURI, null); seriesDs.Add <object>(fo.DicomTag.SeriesInstanceUID, null); seriesDs.Add <object>(fo.DicomTag.SeriesNumber, null); seriesDs.Add <object>(fo.DicomTag.NumberOfSeriesRelatedInstances, null); seriesDs.Add <object>(fo.DicomTag.PerformedProcedureStepStartDate, null); seriesDs.Add <object>(fo.DicomTag.PerformedProcedureStepStartTime, null); //seriesDs.Add<object>(fo.DicomTag.RequestAttributesSequence,null) ; //Not supported yet }
public UncompressedPixelDataWrapper(fo.DicomDataset ds) { if (ds.InternalTransferSyntax.IsEncapsulated) { Dataset = ds.Clone(DicomTransferSyntax.ImplicitVRLittleEndian); } else { // pull uncompressed frame from source pixel data Dataset = ds; } PixelData = DicomPixelData.Create(Dataset); }
protected override fo.DicomDataset GetMediaDataset(fo.DicomDataset data, DicomMediaProperties mediaInfo) { //TODO: this is still not working with when images BPP are not compatible from one Transfer to the other (12/16-bit -> 8-bit) if (!string.IsNullOrWhiteSpace(mediaInfo.TransferSyntax)) { return(data.Clone(fo.DicomTransferSyntax.Parse(mediaInfo.TransferSyntax))); } else if (data.InternalTransferSyntax != fo.DicomTransferSyntax.JPEGProcess1) { return(data.Clone(fo.DicomTransferSyntax.JPEGProcess1)); } return(base.GetMediaDataset(data, mediaInfo)); }
protected virtual void ReadDefaultVr ( fo.DicomTag tag, fo.DicomVR vr, JsonTextReader reader, fo.DicomDataset dataset, int level ) { //if VR was the first property we already read the right thing above, //otherwise we'll got it from the dictionary. Could it be defined after the value? switch (vr.Code) { case fo.DicomVRCode.SQ: { ReadVr_SQ(reader, tag, dataset, level); } break; case fo.DicomVRCode.PN: { ReadVr_PN(reader, tag, dataset); } break; default: { List <string> values = new List <string> ( ); while (reader.Read( ) && reader.TokenType == JsonToken.StartArray) { while (reader.Read( ) && reader.TokenType != JsonToken.EndArray) { values.Add(System.Convert.ToString(reader.Value)); } break; } if (tag == fo.DicomTag.TransferSyntaxUID) { TransferSyntaxUID = values.FirstOrDefault( ); } dataset.AddOrUpdate <string> (vr, tag, values.ToArray( )); } break; } }
public DCloudCommandResult StoreDicom ( fo.DicomDataset dataset, InstanceMetadata metadata ) { IStoreCommand storeCommand = CommandFactory.CreateStoreCommand( ); StoreCommandData storeData = new StoreCommandData( ) { Dataset = dataset, Metadata = metadata }; return(storeCommand.Execute(storeData)); }
protected virtual void ReadDicomItem ( JsonTextReader reader, fo.DicomTag tag, fo.DicomDataset dataset, int level ) { var vr = tag.DictionaryEntry.ValueRepresentations.FirstOrDefault( ); while (reader.Read( ) && reader.TokenType == JsonToken.PropertyName) { string propertyValue = (string)reader.Value; switch (propertyValue) { case JsonConstants.VrField: { reader.Read( ); vr = fo.DicomVR.Parse((string)reader.Value); } break; case JsonConstants.ValueField: { ReadDefaultVr(tag, vr, reader, dataset, level); } break; case JsonConstants.ELEMENT_BULKDATA: { ReadBulkData(tag, vr, reader, dataset, level); } break; case JsonConstants.ELEMENT_INLINEBINARY: { ReadInlineBinary(tag, vr, reader, dataset, level); } break; default: { reader.Skip( ); } break; } } }
public PagedResult <fo.DicomDataset> FindPaged ( fo.DicomDataset request, IQueryOptions options, string queryLevel ) { IEnumerable <IMatchingCondition> conditions = null; conditions = BuildConditions(request, new ConditionFactory( )); return(DoFindPaged(request, options, queryLevel, conditions)); }
private void ReadDicomAttribute(fo.DicomDataset ds, XElement element, int level) { XAttribute vrNode; fo.DicomTag tag; fo.DicomDictionaryEntry dicEntry; fo.DicomVR dicomVR; vrNode = element.Attribute(Constants.ATTRIBUTE_VR); tag = fo.DicomTag.Parse(element.Attribute(Constants.ATTRIBUTE_TAG).Value); dicomVR = null; //if ( tag.ToString ("J") == "00020010" ) //{ // ds.InternalTransferSyntax = ReadValue ( element ).FirstOrDefault ( ) ; //} if (vrNode != null && !string.IsNullOrEmpty(vrNode.Value)) { dicomVR = fo.DicomVR.Parse(vrNode.Value); } if (tag.IsPrivate) { tag = ds.GetPrivateTag(tag); if (null != vrNode) { dicomVR = fo.DicomVR.Parse(vrNode.Value); } } if (null == dicomVR) { dicEntry = fo.DicomDictionary.Default[tag]; dicomVR = dicEntry.ValueRepresentations.FirstOrDefault( ); } if (dicomVR == fo.DicomVR.SQ) { ReadSequence(ds, element, tag, level); } else { ReadElement(ds, element, tag, dicomVR, level); } }
//TODO: is this used? update with fo-dicom public Stream Convert(fo.DicomDataset ds) { //fo.DicomDataset command = new fo.DicomDataset () ; //command[fo.DicomTag.TransferSyntaxUid] = ds[fo.DicomTag.TransferSyntaxUid] ; //DicomMessage message = new DicomMessage (command, ds) ; //DicomPixelData pd = DicomPixelData.CreateFrom ( message ) ; //string tempFile = System.IO.Path.GetTempFileName ( ) ; //System.IO.File.WriteAllBytes ( tempFile, pd.GetFrame (0)); //return new DICOMcloud.Storage.TempStream (new TempFile(tempFile)); return(null); }
protected override fo.DicomDataset GetMediaDataset(fo.DicomDataset data, DicomMediaProperties mediaInfo) { if (mediaInfo.MediaType != MediaType) { throw new InvalidOperationException(string.Format("Invalid media type. Supported media type is:{0} and provided media type is:{1}", MediaType, mediaInfo.MediaType)); } if (!string.IsNullOrWhiteSpace(mediaInfo.TransferSyntax)) { return(data.Clone(fo.DicomTransferSyntax.Parse(mediaInfo.TransferSyntax))); } return(base.GetMediaDataset(data, mediaInfo)); }
private void InsertDicomElement(fo.DicomDataset dicomRequest, string paramKey, string paramValue) { List <string> elements = new List <string>(); elements.AddRange(paramKey.Split('.')); if (elements.Count > 1) { CreateSequence(elements, 0, dicomRequest, paramValue); } else { CreateElement(elements[0], dicomRequest, paramValue); } }
protected virtual void ReadChildren(JsonTextReader reader, fo.DicomDataset dataset, int level) { while (reader.Read( ) && reader.TokenType == JsonToken.PropertyName) { var tag = fo.DicomTag.Parse((string)reader.Value); if (reader.Read( ) && reader.TokenType == JsonToken.StartObject) { ReadDicomItem(reader, tag, dataset, level); } } if (reader.TokenType != JsonToken.EndObject) { throw new JsonReaderException("Malformed DICOM json"); } }
public DicomMediaId ( fo.DicomDataset dataset, int frame, string mediaType, string transferSyntax ) { var dicomObject = new ObjectId( ) { StudyInstanceUID = dataset.GetValueOrDefault(fo.DicomTag.StudyInstanceUID, 0, ""), SeriesInstanceUID = dataset.GetValueOrDefault(fo.DicomTag.SeriesInstanceUID, 0, ""), SOPInstanceUID = dataset.GetValueOrDefault(fo.DicomTag.SOPInstanceUID, 0, ""), Frame = frame }; Init(dicomObject, mediaType, transferSyntax); }
protected override void Upload(fo.DicomDataset dicomDataset, int frame, IStorageLocation storeLocation) { var uncompressedData = new UncompressedPixelDataWrapper(dicomDataset); var buffer = uncompressedData.PixelData.GetFrame(frame - 1); var data = new byte[0]; try { //TODO: check fo-dicom, dicom file with no data will throw an exception althoug //it is wrapped with a RangeByteBuffer but Internal is EmptyBuffer //only way to find out is to ignore exception data = buffer.Data; } catch {} storeLocation.Upload(data); }
private fo.DicomDataset GetTemplateDataset( ) { var ds = new fo.DicomDataset( ); ds.Add(fo.DicomTag.PatientID, "test-pid"); ds.Add(fo.DicomTag.PatientName, "test^patient name"); ds.Add(fo.DicomTag.StudyInstanceUID, Study1UID); ds.Add(fo.DicomTag.StudyID, "test-studyid"); ds.Add(fo.DicomTag.SeriesInstanceUID, Series1UID); ds.Add(fo.DicomTag.SeriesNumber, 1); ds.Add(fo.DicomTag.Modality, "XA"); ds.Add(fo.DicomTag.SOPInstanceUID, Instance1UID); ds.Add(fo.DicomTag.SOPClassUID, "test.instance.class.uid"); ds.Add(fo.DicomTag.InstanceNumber, 1); return(ds); }
private void FillDataset(Dicom.DicomDataset dataset) { //type 1 attributes. dataset.Add(DicomTag.SOPClassUID, DicomUID.SecondaryCaptureImageStorage); dataset.Add(DicomTag.StudyInstanceUID, GenerateUid()); dataset.Add(DicomTag.SeriesInstanceUID, GenerateUid()); dataset.Add(DicomTag.SOPInstanceUID, GenerateUid()); //type 2 attributes dataset.Add(DicomTag.PatientID, "12345"); dataset.Add(DicomTag.PatientName, PatientName); dataset.Add(DicomTag.PatientBirthDate, PatientDateOfBirth); switch (patientSex) { case Sex.Male: dataset.Add(DicomTag.PatientSex, "M"); break; case Sex.Female: dataset.Add(DicomTag.PatientSex, "F"); break; case Sex.Other: dataset.Add(DicomTag.PatientSex, "O"); break; default: break; } dataset.Add(DicomTag.StudyDate, examinationDate); dataset.Add(DicomTag.StudyTime, examinationDate); dataset.Add(DicomTag.AccessionNumber, string.Empty); dataset.Add(DicomTag.ReferringPhysicianName, string.Empty); dataset.Add(DicomTag.StudyID, "1"); dataset.Add(DicomTag.SeriesNumber, "1"); dataset.Add(DicomTag.ModalitiesInStudy, "CR"); dataset.Add(DicomTag.Modality, "CR"); dataset.Add(DicomTag.NumberOfStudyRelatedInstances, "1"); dataset.Add(DicomTag.NumberOfStudyRelatedSeries, "1"); dataset.Add(DicomTag.NumberOfSeriesRelatedInstances, "1"); dataset.Add(DicomTag.PatientOrientation, "F/A"); dataset.Add(DicomTag.ImageLaterality, "U"); dataset.Add(DicomTag.StudyDescription, Comment); }
//TODO: update this to return a type showing what objects got deleted e.g. IObjectId[] //the "reuest" dataset is assumed to have the Object ID values. However, //an extended implementation might send a query dataset and this method will query the DB and generate multiple Object IDs //Example: the request dataset has a date range, wild-card or SOP Class UID... public DCloudCommandResult Delete ( fo.DicomDataset request, ObjectQueryLevel level ) { DCloudCommandResult deleteResult = null; IDeleteCommand deleteCommand = CommandFactory.CreateDeleteCommand( ); DeleteCommandData deleteData = new DeleteCommandData( ) { Instances = new List <ObjectId> ( ) { new ObjectId(request) }, DeleteLevel = level }; return(deleteResult = deleteCommand.Execute(deleteData)); }
protected virtual IEnumerable <IMatchingCondition> BuildConditions ( fo.DicomDataset request ) { ConditionFactory condFactory = new ConditionFactory( ); IEnumerable <IMatchingCondition> conditions; condFactory.BeginProcessingElements( ); foreach (var element in request) { condFactory.ProcessElement(element); } conditions = condFactory.EndProcessingElements( ); return(conditions); }
protected override void Upload ( fo.DicomDataset dicomObject, int frame, IStorageLocation storeLocation, DicomMediaProperties mediaProperties ) { var frameIndex = frame - 1; var dicomImage = new DicomImage(dicomObject, frameIndex); var bitmap = dicomImage.RenderImage(frameIndex).AsBitmap(); var stream = new MemoryStream( ); bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg); stream.Position = 0; storeLocation.Upload(stream, MediaType); }