同步遮盖影像初步预提交
parent
5e04634837
commit
152c5200cb
|
|
@ -178,11 +178,10 @@ public static class DicomPixelMasker
|
||||||
public static async Task<MemoryStream> MaskAsync(
|
public static async Task<MemoryStream> MaskAsync(
|
||||||
Stream input,
|
Stream input,
|
||||||
IEnumerable<MaskRegion> regions,
|
IEnumerable<MaskRegion> regions,
|
||||||
DicomMaskOptions? options = null,
|
DicomMaskOptions? options = null)
|
||||||
CancellationToken cancellationToken = default)
|
|
||||||
{
|
{
|
||||||
var output = new MemoryStream();
|
var output = new MemoryStream();
|
||||||
await MaskAsync(input, output, regions, options, cancellationToken).ConfigureAwait(false);
|
await MaskAsync(input, output, regions, options).ConfigureAwait(false);
|
||||||
output.Position = 0;
|
output.Position = 0;
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
@ -211,6 +210,7 @@ public static class DicomPixelMasker
|
||||||
var workingDataset = workingFile.Dataset;
|
var workingDataset = workingFile.Dataset;
|
||||||
|
|
||||||
var originalPhotometric = originalDataset.GetSingleValueOrDefault(DicomTag.PhotometricInterpretation, string.Empty);
|
var originalPhotometric = originalDataset.GetSingleValueOrDefault(DicomTag.PhotometricInterpretation, string.Empty);
|
||||||
|
|
||||||
Console.WriteLine($"Original Photometric={originalPhotometric}, Original TS={originalTs.UID.UID}");
|
Console.WriteLine($"Original Photometric={originalPhotometric}, Original TS={originalTs.UID.UID}");
|
||||||
|
|
||||||
var rows = workingDataset.GetSingleValue<int>(DicomTag.Rows);
|
var rows = workingDataset.GetSingleValue<int>(DicomTag.Rows);
|
||||||
|
|
|
||||||
|
|
@ -2965,6 +2965,12 @@
|
||||||
<param name="inQuery"></param>
|
<param name="inQuery"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:IRaCIS.Core.Application.Service.ImageAndDoc.StudyService.StudyMaskImage(IRaCIS.Core.Application.Contracts.StudyMaskImageCommand)">
|
||||||
|
<summary>
|
||||||
|
标注遮盖影像
|
||||||
|
</summary>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:IRaCIS.Core.Application.Service.ImageAndDoc.StudyService.Preview(System.Guid)">
|
<member name="M:IRaCIS.Core.Application.Service.ImageAndDoc.StudyService.Preview(System.Guid)">
|
||||||
<summary> 指定资源Id,渲染Dicom检查的Jpeg预览图像 </summary>
|
<summary> 指定资源Id,渲染Dicom检查的Jpeg预览图像 </summary>
|
||||||
<param name="studyId"> Dicom检查的Id </param>
|
<param name="studyId"> Dicom检查的Id </param>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using FellowOakDicom;
|
using FellowOakDicom;
|
||||||
|
using IRaCIS.Core.Application.Helper;
|
||||||
using IRaCIS.Core.Application.Service.ImageAndDoc.DTO;
|
using IRaCIS.Core.Application.Service.ImageAndDoc.DTO;
|
||||||
using IRaCIS.Core.Domain.Share;
|
using IRaCIS.Core.Domain.Share;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
@ -963,7 +964,7 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public class SubjectVisitMarkQuery:PageInput
|
public class SubjectVisitMarkQuery : PageInput
|
||||||
{
|
{
|
||||||
public Guid TrialId { get; set; }
|
public Guid TrialId { get; set; }
|
||||||
|
|
||||||
|
|
@ -1047,4 +1048,15 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
|
|
||||||
public List<StudyBasicInfo> UploadStudyList { get; set; }
|
public List<StudyBasicInfo> UploadStudyList { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class StudyMaskImageCommand
|
||||||
|
{
|
||||||
|
public Guid? SeriesId { get; set; }
|
||||||
|
|
||||||
|
public List<Guid>? InstanceIdList { get; set; }
|
||||||
|
|
||||||
|
public List<MaskRegion> MaskRegionList { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ using IRaCIS.Core.Infrastructure;
|
||||||
using Medallion.Threading;
|
using Medallion.Threading;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.Drawing;
|
||||||
using ZiggyCreatures.Caching.Fusion;
|
using ZiggyCreatures.Caching.Fusion;
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||||
|
|
@ -25,7 +26,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||||
IRepository<StudyMonitor> _studyMonitorRepository,
|
IRepository<StudyMonitor> _studyMonitorRepository,
|
||||||
IRepository<SystemAnonymization> _systemAnonymizationRepository,
|
IRepository<SystemAnonymization> _systemAnonymizationRepository,
|
||||||
IRepository<NoneDicomStudy> _noneDicomStudyRepository,
|
IRepository<NoneDicomStudy> _noneDicomStudyRepository,
|
||||||
IDistributedLockProvider _distributedLockProvider,
|
IDistributedLockProvider _distributedLockProvider, IOSSService _oSSService,
|
||||||
IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer, IFusionCache _fusionCache) : BaseService, IStudyService
|
IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer, IFusionCache _fusionCache) : BaseService, IStudyService
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -66,6 +67,53 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标注遮盖影像
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<IResponseOutput> StudyMaskImage(StudyMaskImageCommand inCommand)
|
||||||
|
{
|
||||||
|
if (inCommand.SeriesId == null && inCommand.InstanceIdList == null)
|
||||||
|
{
|
||||||
|
return ResponseOutput.NotOk("SeriesId and InstanceIdList can not both be null");
|
||||||
|
}
|
||||||
|
|
||||||
|
var instancePathList = new List<string>();
|
||||||
|
|
||||||
|
if (inCommand.SeriesId == null && inCommand.InstanceIdList != null)
|
||||||
|
{
|
||||||
|
instancePathList = await _dicomInstanceRepository.Where(t => inCommand.InstanceIdList.Contains(t.Id)).Select(t => t.Path).ToListAsync();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
instancePathList = await _dicomInstanceRepository.Where(t => t.SeriesId == inCommand.SeriesId).Select(t => t.Path).ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var path in instancePathList)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var inputStream = await _oSSService.GetStreamFromOSSAsync(path);
|
||||||
|
|
||||||
|
var outPutStream = await DicomPixelMasker.MaskAsync(inputStream, inCommand.MaskRegionList);
|
||||||
|
|
||||||
|
var prefix = path.Substring(1, path.LastIndexOf('/') - 1);
|
||||||
|
await _oSSService.UploadToOSSAsync(outPutStream, prefix, $"MaskImage_{Path.GetFileName(path)}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
Log.Logger.Error(ex, $"StudyMaskImage Error for InstanceIdList Path:{path} {ex.Message}");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseOutput.Ok();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
[TrialGlobalLimit("AfterStopCannNotOpt")]
|
[TrialGlobalLimit("AfterStopCannNotOpt")]
|
||||||
|
|
||||||
public async Task<IResponseOutput> PreArchiveDicomStudy(PreArchiveDicomStudyCommand preArchiveStudyCommand)
|
public async Task<IResponseOutput> PreArchiveDicomStudy(PreArchiveDicomStudyCommand preArchiveStudyCommand)
|
||||||
|
|
@ -324,7 +372,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var @lock2 = _distributedLockProvider.CreateLock($"StudyCommit");
|
var @lock2 = _distributedLockProvider.CreateLock($"StudyCommit");
|
||||||
|
|
@ -334,7 +382,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||||
await _dicomInstanceRepository.SaveChangesAsync();
|
await _dicomInstanceRepository.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
await _fileUploadRecordRepository.BatchUpdateNoTrackingAsync(t => t.UploadBatchId == incommand.UploadBatchId, u => new FileUploadRecord() { StudyCode = findStudy.StudyCode });
|
await _fileUploadRecordRepository.BatchUpdateNoTrackingAsync(t => t.UploadBatchId == incommand.UploadBatchId, u => new FileUploadRecord() { StudyCode = findStudy.StudyCode });
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
@ -437,7 +485,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||||
Id = t.Id,
|
Id = t.Id,
|
||||||
|
|
||||||
Bodypart = t.BodyPart,
|
Bodypart = t.BodyPart,
|
||||||
BodyPartForEditOther=t.BodyPartForEditOther,
|
BodyPartForEditOther = t.BodyPartForEditOther,
|
||||||
|
|
||||||
Modalities = t.Modality,
|
Modalities = t.Modality,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -129,8 +129,8 @@ namespace IRaCIS.Core.Application.Service
|
||||||
public async Task<IResponseOutput> MaskImage()
|
public async Task<IResponseOutput> MaskImage()
|
||||||
{
|
{
|
||||||
|
|
||||||
var sourceDir = @"D:\images";
|
var sourceDir = @"D:\images\11\像素匿名\隐私信息2&测量值\08\08017\基线(V1)\ST01371_1970-01-01_US\IMAGE";
|
||||||
var targetDir = @"D:\images\after";
|
var targetDir = @"D:\images\11\像素匿名\隐私信息2&测量值\08\08017\基线(V1)\ST01371_1970-01-01_US\IMAGE\after";
|
||||||
|
|
||||||
Directory.CreateDirectory(targetDir);
|
Directory.CreateDirectory(targetDir);
|
||||||
var regions = new[]
|
var regions = new[]
|
||||||
|
|
@ -138,7 +138,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
new MaskRegion(0, 0, 200, 200)
|
new MaskRegion(0, 0, 200, 200)
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach (var inputPath in Directory.EnumerateFiles(sourceDir, "*.dcm", SearchOption.TopDirectoryOnly))
|
foreach (var inputPath in Directory.EnumerateFiles(sourceDir, "IM_*", SearchOption.TopDirectoryOnly))
|
||||||
{
|
{
|
||||||
var relativePath = Path.GetRelativePath(sourceDir, inputPath);
|
var relativePath = Path.GetRelativePath(sourceDir, inputPath);
|
||||||
var outputPath = Path.Combine(targetDir, relativePath);
|
var outputPath = Path.Combine(targetDir, relativePath);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue