本文整理汇总了C#中StudyXml类的典型用法代码示例。如果您正苦于以下问题:C# StudyXml类的具体用法?C# StudyXml怎么用?C# StudyXml使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StudyXml类属于命名空间,在下文中一共展示了StudyXml类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveInstanceFromStudyXmlCommand
public RemoveInstanceFromStudyXmlCommand(StudyStorageLocation location, StudyXml studyXml, DicomFile file)
:base("Remove Instance From Study Xml", true)
{
_studyLocation = location;
_file = file;
_studyXml = studyXml;
}
示例2: LoadStudyFromStudyXml
/// <summary>
/// Load all of the instances in a given <see cref="StudyXml"/> file into the component for sending.
/// </summary>
/// <param name="location"></param>
/// <param name="studyXml">The <see cref="StudyXml"/> file to load from</param>
public void LoadStudyFromStudyXml(StudyLocation location, StudyXml studyXml)
{
foreach (SeriesXml seriesXml in studyXml)
{
LoadSeriesFromSeriesXml(studyXml, location, seriesXml, studyXml.PatientsName, studyXml.PatientId);
}
}
示例3: TestSopClass
public void TestSopClass()
{
List<DicomFile> images = SetupImages(4);
string seriesUid = images[0].DataSet[DicomTags.SeriesInstanceUid].ToString();
images[0].MediaStorageSopClassUid = SopClass.EnhancedCtImageStorageUid;
images[1].MediaStorageSopClassUid = SopClass.EnhancedMrImageStorageUid;
images[2].MediaStorageSopClassUid = SopClass.EnhancedSrStorageUid;
images[3].MediaStorageSopClassUid = SopClass.EnhancedXaImageStorageUid;
StudyXml xml = new StudyXml();
foreach (DicomFile file in images)
xml.AddFile(file);
XmlDocument doc = xml.GetMemento(new StudyXmlOutputSettings());
Assert.AreEqual(xml[seriesUid][images[0].DataSet[DicomTags.SopInstanceUid]].SopClass.Uid, SopClass.EnhancedCtImageStorageUid);
Assert.AreEqual(xml[seriesUid][images[1].DataSet[DicomTags.SopInstanceUid]].SopClass.Uid, SopClass.EnhancedMrImageStorageUid);
Assert.AreEqual(xml[seriesUid][images[2].DataSet[DicomTags.SopInstanceUid]].SopClass.Uid, SopClass.EnhancedSrStorageUid);
Assert.AreEqual(xml[seriesUid][images[3].DataSet[DicomTags.SopInstanceUid]].SopClass.Uid, SopClass.EnhancedXaImageStorageUid);
xml = new StudyXml();
xml.SetMemento(doc);
Assert.AreEqual(xml[seriesUid][images[0].DataSet[DicomTags.SopInstanceUid]].SopClass.Uid, SopClass.EnhancedCtImageStorageUid);
Assert.AreEqual(xml[seriesUid][images[1].DataSet[DicomTags.SopInstanceUid]].SopClass.Uid, SopClass.EnhancedMrImageStorageUid);
Assert.AreEqual(xml[seriesUid][images[2].DataSet[DicomTags.SopInstanceUid]].SopClass.Uid, SopClass.EnhancedSrStorageUid);
Assert.AreEqual(xml[seriesUid][images[3].DataSet[DicomTags.SopInstanceUid]].SopClass.Uid, SopClass.EnhancedXaImageStorageUid);
}
示例4: CreateStudyZipCommand
/// <summary>
/// Constructor
/// </summary>
/// <param name="zipFile">The path of the zip file to create</param>
/// <param name="studyXml">The <see cref="StudyXml"/> file describing the contents of the study.</param>
/// <param name="studyFolder">The folder the study is stored in.</param>
/// <param name="tempFolder">The folder for tempory files when creating the zip file.</param>
public CreateStudyZipCommand(string zipFile, StudyXml studyXml, string studyFolder, string tempFolder) : base("Create study zip file",true)
{
_zipFile = zipFile;
_studyXml = studyXml;
_studyFolder = studyFolder;
_tempFolder = tempFolder;
}
示例5: CreateTestStudy1
protected Study CreateTestStudy1()
{
var studyUid = "1.2.3";
var sops = base.SetupMRSeries(4, 5, studyUid);
var xml = new StudyXml(studyUid);
var seriesUids = new Dictionary<string, string>();
var seriesModalities = new Dictionary<string, string>();
var modalities = new[] { "MR", "MR", "SC", "KO" };
foreach (var sop in sops)
{
//Make the UIDs constant.
var seriesUid = sop[DicomTags.SeriesInstanceUid].ToString();
if (!seriesUids.ContainsKey(seriesUid))
{
seriesModalities[seriesUid] = modalities[seriesUids.Count];
seriesUids[seriesUid] = string.Format("1.2.3.{0}", seriesUids.Count + 1);
}
var modality = seriesModalities[seriesUid];
seriesUid = seriesUids[seriesUid];
sop[DicomTags.SeriesInstanceUid].SetString(0, seriesUid);
sop[DicomTags.Modality].SetString(0, modality);
var file = new DicomFile("", new DicomAttributeCollection(), sop);
xml.AddFile(file);
}
var study = new Study();
study.Update(xml);
return study;
}
示例6: ConstructorTest
public void ConstructorTest()
{
StudyXml stream = new StudyXml();
stream = new StudyXml("1.1.1");
}
示例7: CreationTest
public void CreationTest()
{
IList<DicomAttributeCollection> instanceList;
string studyInstanceUid = DicomUid.GenerateUid().UID;
instanceList = SetupMRSeries(4, 10, studyInstanceUid);
StudyXml studyXml = new StudyXml(studyInstanceUid);
string studyXmlFilename = Path.GetTempFileName();
foreach (DicomAttributeCollection instanceCollection in instanceList)
{
instanceCollection[DicomTags.PixelData] = null;
DicomFile theFile = new DicomFile("test", new DicomAttributeCollection(), instanceCollection);
SetupMetaInfo(theFile);
studyXml.AddFile(theFile);
WriteStudyStream(studyXmlFilename, studyXml);
}
StudyXml newXml = LoadStudyStream(studyXmlFilename);
if (!Compare(newXml, instanceList))
Assert.Fail("Comparison of StudyXML failed against base loaded from disk");
if (!Compare(studyXml, instanceList))
Assert.Fail("Comparison of StudyXML failed against base in memory");
}
示例8: RemoveSeriesFromStudyXml
public RemoveSeriesFromStudyXml(StudyXml studyXml, string seriesUid)
: base(String.Format("Remove series {0} from study XML of study {1}", seriesUid, studyXml.StudyInstanceUid), true)
{
_studyXml = studyXml;
_seriesUid = seriesUid;
_studyInstanceUid = studyXml.StudyInstanceUid;
}
示例9: StudyRulesEngine
public StudyRulesEngine(ServerRulesEngine studyRulesEngine, StudyStorageLocation location, ServerPartition partition, StudyXml studyXml)
{
_studyRulesEngine = studyRulesEngine;
_studyXml = studyXml;
_location = location;
_partition = partition ?? ServerPartition.Load(_location.ServerPartitionKey);
}
示例10: InsertOrUpdateStudyCommand
public InsertOrUpdateStudyCommand(StudyLocation location, StudyXml xml, UpdateReason reason) : base("Insert or Update Study Command")
{
_studyInstanceUid = xml.StudyInstanceUid;
_studyXml = xml;
_reason = reason;
_location = location;
}
示例11: LoadInstance
/// <summary>
/// Load the first instance from the first series of the StudyXml file for a study.
/// </summary>
/// <param name="location">The storage location of the study.</param>
/// <returns></returns>
protected static DicomFile LoadInstance(StudyStorageLocation location)
{
string studyXml = Path.Combine(location.GetStudyPath(), location.StudyInstanceUid + ".xml");
if (!File.Exists(studyXml))
{
return null;
}
FileStream stream = FileStreamOpener.OpenForRead(studyXml, FileMode.Open);
var theDoc = new XmlDocument();
StudyXmlIo.Read(theDoc, stream);
stream.Close();
stream.Dispose();
var xml = new StudyXml();
xml.SetMemento(theDoc);
IEnumerator<SeriesXml> seriesEnumerator = xml.GetEnumerator();
if (seriesEnumerator.MoveNext())
{
SeriesXml seriesXml = seriesEnumerator.Current;
IEnumerator<InstanceXml> instanceEnumerator = seriesXml.GetEnumerator();
if (instanceEnumerator.MoveNext())
{
InstanceXml instance = instanceEnumerator.Current;
var file = new DicomFile("file.dcm",new DicomAttributeCollection(), instance.Collection)
{TransferSyntax = instance.TransferSyntax};
return file;
}
}
return null;
}
示例12: OnExecute
protected override void OnExecute(CommandProcessor theProcessor)
{
StudyXml currentXml = LoadStudyXml();
_newXml = new StudyXml(_studyInstanceUid);
foreach (SeriesXml series in currentXml)
{
string seriesPath = Path.Combine(_rootPath, series.SeriesInstanceUid);
if (!Directory.Exists(seriesPath))
{
Platform.Log(LogLevel.Info, "RebuildXML: series folder {0} is missing", seriesPath);
continue;
}
foreach (InstanceXml instance in series)
{
string instancePath = Path.Combine(seriesPath, instance.SopInstanceUid + ServerPlatform.DicomFileExtension);
if (!File.Exists(instancePath))
{
Platform.Log(LogLevel.Info, "RebuildXML: file {0} is missing", instancePath);
}
else
{
if (!theProcessor.ExecuteSubCommand(this, new InsertInstanceXmlCommand(_newXml, instancePath)))
throw new ApplicationException(theProcessor.FailureReason);
}
}
}
if (!theProcessor.ExecuteSubCommand(this, new SaveXmlCommand(_newXml, _rootPath, _studyInstanceUid)))
throw new ApplicationException(theProcessor.FailureReason);
}
示例13: OnExecute
/// <summary>
/// Apply the rules.
/// </summary>
/// <remarks>
/// When rules are applied, we are simply adding new <see cref="ServerDatabaseCommand"/> instances
/// for the rules to the currently executing <see cref="ServerCommandProcessor"/>. They will be
/// executed after all other rules have been executed.
/// </remarks>
protected override void OnExecute(CommandProcessor theProcessor)
{
string studyXmlFile = Path.Combine(_directory, String.Format("{0}.xml", _studyInstanceUid));
StudyXml theXml = new StudyXml(_studyInstanceUid);
if (File.Exists(studyXmlFile))
{
using (Stream fileStream = FileStreamOpener.OpenForRead(studyXmlFile, FileMode.Open))
{
var theMemento = new StudyXmlMemento();
StudyXmlIo.Read(theMemento, fileStream);
theXml.SetMemento(theMemento);
fileStream.Close();
}
}
else
{
string errorMsg = String.Format("Unable to load study XML file of restored study: {0}", studyXmlFile);
Platform.Log(LogLevel.Error, errorMsg);
throw new ApplicationException(errorMsg);
}
DicomFile defaultFile = null;
bool rulesExecuted = false;
foreach (SeriesXml seriesXml in theXml)
{
foreach (InstanceXml instanceXml in seriesXml)
{
// Skip non-image objects
if (instanceXml.SopClass.Equals(SopClass.KeyObjectSelectionDocumentStorage)
|| instanceXml.SopClass.Equals(SopClass.GrayscaleSoftcopyPresentationStateStorageSopClass)
|| instanceXml.SopClass.Equals(SopClass.BlendingSoftcopyPresentationStateStorageSopClass)
|| instanceXml.SopClass.Equals(SopClass.ColorSoftcopyPresentationStateStorageSopClass))
{
// Save the first one encountered, just in case the whole study is non-image objects.
if (defaultFile == null)
defaultFile = new DicomFile("test", new DicomAttributeCollection(), instanceXml.Collection);
continue;
}
DicomFile file = new DicomFile("test", new DicomAttributeCollection(), instanceXml.Collection);
_context.Message = file;
_engine.Execute(_context);
rulesExecuted = true;
break;
}
if (rulesExecuted) break;
}
if (!rulesExecuted && defaultFile != null)
{
_context.Message = defaultFile;
_engine.Execute(_context);
}
}
示例14: RemoveSopInstanceFromStudyXmlCommand
public RemoveSopInstanceFromStudyXmlCommand(StudyXml studyXml, string seriesUid, string sopInstanceUid)
: base(String.Format("Remove sop {0} from study XML of study {1}", sopInstanceUid, studyXml.StudyInstanceUid), true)
{
_studyXml = studyXml;
_seriesUid = seriesUid;
_sopInstanceUid = sopInstanceUid;
_studyInstanceUid = studyXml.StudyInstanceUid;
}
示例15: RemoveInstanceFromStudyXmlCommand
public RemoveInstanceFromStudyXmlCommand(StudyStorageLocation location, StudyXml studyXml, string seriesInstanceUid, string sopInstanceUid)
: base("RemoveInstanceFromStudyXmlCommand", true)
{
_studyLocation = location;
_seriesInstanceUid = seriesInstanceUid;
_sopInstanceUid = sopInstanceUid;
_studyXml = studyXml;
}