I am learning how to interact with PACS and am using Fo-Dicom Unity Asset Store Package.
So far I am able to successfully find the patient study and series data.
For downloading the images, I have made some implementation using C-Move and CStoreSCP but when I run it, it only downloads a single DICOM image (even when I am trying for whole series) and I guess it is just downloading the last DICOM image in the series.
public class CStoreSCP : DicomService, IDicomServiceProvider, IDicomCStoreProvider, IDicomCEchoProvider
{
public delegate DicomCStoreResponse OnCStoreRequestCallback(DicomCStoreRequest request);
public static event OnCStoreRequestCallback CStoreRequestCallBack;
private static readonly DicomTransferSyntax[] AcceptedTransferSyntaxes = new DicomTransferSyntax[]
{
DicomTransferSyntax.ExplicitVRLittleEndian,
DicomTransferSyntax.ExplicitVRBigEndian,
DicomTransferSyntax.ImplicitVRLittleEndian
};
private static readonly DicomTransferSyntax[] AcceptedImageTransferSyntaxes = new DicomTransferSyntax[]
{
// Lossless
DicomTransferSyntax.JPEGLSLossless,
DicomTransferSyntax.JPEG2000Lossless,
DicomTransferSyntax.JPEGProcess14SV1,
DicomTransferSyntax.JPEGProcess14,
DicomTransferSyntax.RLELossless,
// Lossy
DicomTransferSyntax.JPEGLSNearLossless,
DicomTransferSyntax.JPEG2000Lossy,
DicomTransferSyntax.JPEGProcess1,
DicomTransferSyntax.JPEGProcess2_4,
// Uncompressed
DicomTransferSyntax.ExplicitVRLittleEndian,
DicomTransferSyntax.ExplicitVRBigEndian,
DicomTransferSyntax.ImplicitVRLittleEndian
};
public CStoreSCP(INetworkStream stream, Encoding fallbackEncoding, Dicom.Log.Logger log)
: base(stream, fallbackEncoding, log)
{
}
public Task OnReceiveAssociationRequestAsync(DicomAssociation association)
{
Debug.LogError("association request : called AE " + association.CalledAE + " calling ae : " + association.CallingAE);
if (association.CalledAE != "MYSCP")
{
return SendAssociationRejectAsync(
DicomRejectResult.Permanent,
DicomRejectSource.ServiceUser,
DicomRejectReason.CalledAENotRecognized);
}
foreach (var pc in association.PresentationContexts)
{
if (pc.AbstractSyntax == DicomUID.Verification)
{
pc.AcceptTransferSyntaxes(AcceptedTransferSyntaxes);
Debug.LogError("condition 1 calling");
}
else if (pc.AbstractSyntax.StorageCategory != DicomStorageCategory.None)
{
pc.AcceptTransferSyntaxes(AcceptedImageTransferSyntaxes);
Debug.LogError("condition 2 calling");
}
}
return SendAssociationAcceptAsync(association);
}
public Task OnReceiveAssociationReleaseRequestAsync()
{
return SendAssociationReleaseResponseAsync();
}
public void OnReceiveAbort(DicomAbortSource source, DicomAbortReason reason)
{
}
public void OnConnectionClosed(Exception exception)
{
Debug.LogError("connection closed");
}
public string storagePath;
//public static OnCStoreRequestCallback OnCStoreRequestCallBack;
public DicomCStoreResponse OnCStoreRequest(DicomCStoreRequest request)
{
// Debug.LogError("asdosahjd : dataset " + request.Dataset.ToString());
Debug.LogError(request.Dataset.WriteToString());
var studyUid = request.Dataset.Get<string>(DicomTag.StudyInstanceUID,"not found");
var instUid = request.SOPInstanceUID.UID;
storagePath = "C:/Users/user/Downloads/Series4";
//var path = Path.GetFullPath(storagePath);
//path = Path.Combine(path, studyUid);
var path = storagePath + "/" + studyUid;
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
path = Path.Combine(path, instUid) + ".dcm";
request.File.Save(path);
//if (CStoreRequestCallBack! = null)
//{
// return OnCStoreRequestCallBack(request);
//}
Debug.LogError("cstore request called");
return new DicomCStoreResponse(request, DicomStatus.NoSuchActionType);
//return new DicomCStoreResponse(request, DicomStatus.Success);
}
public void OnCStoreRequestException(string tempFileName, Exception e)
{
// let library handle logging and error response
}
public DicomCEchoResponse OnCEchoRequest(DicomCEchoRequest request)
{
return new DicomCEchoResponse(request, DicomStatus.Success);
}
}
When I run the code. only a single file gets downloaded and in the CMoveRequest response I get Failure [c000: Cannot understand]