Compare commits

..

No commits in common. "8259e2fea3cad59d5edaed6c2321d470788dff6b" and "99a1690481d69d8d15647d358901ca9dcad4b448" have entirely different histories.

5 changed files with 11 additions and 77 deletions

View File

@ -178,10 +178,11 @@ public static class DicomPixelMasker
public static async Task<MemoryStream> MaskAsync(
Stream input,
IEnumerable<MaskRegion> regions,
DicomMaskOptions? options = null)
DicomMaskOptions? options = null,
CancellationToken cancellationToken = default)
{
var output = new MemoryStream();
await MaskAsync(input, output, regions, options).ConfigureAwait(false);
await MaskAsync(input, output, regions, options, cancellationToken).ConfigureAwait(false);
output.Position = 0;
return output;
}
@ -210,7 +211,6 @@ public static class DicomPixelMasker
var workingDataset = workingFile.Dataset;
var originalPhotometric = originalDataset.GetSingleValueOrDefault(DicomTag.PhotometricInterpretation, string.Empty);
Console.WriteLine($"Original Photometric={originalPhotometric}, Original TS={originalTs.UID.UID}");
var rows = workingDataset.GetSingleValue<int>(DicomTag.Rows);

View File

@ -2965,12 +2965,6 @@
<param name="inQuery"></param>
<returns></returns>
</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)">
<summary> 指定资源Id渲染Dicom检查的Jpeg预览图像 </summary>
<param name="studyId"> Dicom检查的Id </param>

View File

@ -1,5 +1,4 @@
using FellowOakDicom;
using IRaCIS.Core.Application.Helper;
using IRaCIS.Core.Application.Service.ImageAndDoc.DTO;
using IRaCIS.Core.Domain.Share;
using Newtonsoft.Json;
@ -982,7 +981,7 @@ namespace IRaCIS.Core.Application.Contracts
}
public class SubjectVisitMarkQuery : PageInput
public class SubjectVisitMarkQuery:PageInput
{
public Guid TrialId { get; set; }
@ -1066,15 +1065,4 @@ namespace IRaCIS.Core.Application.Contracts
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; }
}
}

View File

@ -7,7 +7,6 @@ using IRaCIS.Core.Infrastructure;
using Medallion.Threading;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Drawing;
using ZiggyCreatures.Caching.Fusion;
namespace IRaCIS.Core.Application.Service.ImageAndDoc
@ -26,7 +25,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
IRepository<StudyMonitor> _studyMonitorRepository,
IRepository<SystemAnonymization> _systemAnonymizationRepository,
IRepository<NoneDicomStudy> _noneDicomStudyRepository,
IDistributedLockProvider _distributedLockProvider, IOSSService _oSSService,
IDistributedLockProvider _distributedLockProvider,
IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer, IFusionCache _fusionCache) : BaseService, IStudyService
{
@ -67,53 +66,6 @@ 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")]
public async Task<IResponseOutput> PreArchiveDicomStudy(PreArchiveDicomStudyCommand preArchiveStudyCommand)
@ -372,7 +324,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
}
var @lock2 = _distributedLockProvider.CreateLock($"StudyCommit");
@ -382,7 +334,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
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)
{
@ -485,7 +437,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
Id = t.Id,
Bodypart = t.BodyPart,
BodyPartForEditOther = t.BodyPartForEditOther,
BodyPartForEditOther=t.BodyPartForEditOther,
Modalities = t.Modality,

View File

@ -129,8 +129,8 @@ namespace IRaCIS.Core.Application.Service
public async Task<IResponseOutput> MaskImage()
{
var sourceDir = @"D:\images\11\像素匿名\隐私信息2&测量值\08\08017\基线V1\ST01371_1970-01-01_US\IMAGE";
var targetDir = @"D:\images\11\像素匿名\隐私信息2&测量值\08\08017\基线V1\ST01371_1970-01-01_US\IMAGE\after";
var sourceDir = @"D:\images";
var targetDir = @"D:\images\after";
Directory.CreateDirectory(targetDir);
var regions = new[]
@ -138,7 +138,7 @@ namespace IRaCIS.Core.Application.Service
new MaskRegion(0, 0, 200, 200)
};
foreach (var inputPath in Directory.EnumerateFiles(sourceDir, "IM_*", SearchOption.TopDirectoryOnly))
foreach (var inputPath in Directory.EnumerateFiles(sourceDir, "*.dcm", SearchOption.TopDirectoryOnly))
{
var relativePath = Path.GetRelativePath(sourceDir, inputPath);
var outputPath = Path.Combine(targetDir, relativePath);