|
|
@@ -404,14 +404,14 @@ export interface SaveWindowCenterWidthResponse {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 保存窗宽窗位到 dcm
|
|
|
- *
|
|
|
+ * 保存窗位到 dcm
|
|
|
+ *
|
|
|
* @param sopInstanceUid 图像实例 UID (SOP Instance UID)
|
|
|
* @param windowCenter 窗位
|
|
|
* @param windowWidth 窗宽
|
|
|
* @returns 保存结果
|
|
|
* @throws 当保存失败时抛出错误
|
|
|
- *
|
|
|
+ *
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
* await saveWindowCenterWidth('1.2.276.0.1000000.5.1.4.701601461.19649.1749545373.668671', 50, 100);
|
|
|
@@ -441,3 +441,216 @@ export const saveWindowCenterWidth = async (
|
|
|
throw error;
|
|
|
}
|
|
|
};
|
|
|
+
|
|
|
+// =============================================================================
|
|
|
+// 图像处理v2 API
|
|
|
+// =============================================================================
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取tiff图像响应类型
|
|
|
+ */
|
|
|
+export interface GetTiffResponse {
|
|
|
+ /** 响应码 */
|
|
|
+ code: string;
|
|
|
+ /** 描述信息 */
|
|
|
+ description: string;
|
|
|
+ /** 解决方案 */
|
|
|
+ solution: string;
|
|
|
+ /** 文件数据 */
|
|
|
+ data: File;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取tiff图像(公开接口)
|
|
|
+ *
|
|
|
+ * @param filename tiff文件名
|
|
|
+ * @returns tiff文件 Blob
|
|
|
+ * @throws 当获取失败时抛出错误
|
|
|
+ *
|
|
|
+ * @example
|
|
|
+ * ```typescript
|
|
|
+ * const tiffBlob = await getTiffImagePublic('1.2.276.0.1000000.5.1.4.dcm.tiff');
|
|
|
+ * const blobUrl = URL.createObjectURL(tiffBlob);
|
|
|
+ * ```
|
|
|
+ */
|
|
|
+export const getTiffImagePublic = async (
|
|
|
+ filename: string
|
|
|
+): Promise<Blob> => {
|
|
|
+ try {
|
|
|
+ const response = await axiosInstance.get(
|
|
|
+ `/pub/tif/${filename}`,
|
|
|
+ {
|
|
|
+ responseType: 'blob', // 重要:指定响应类型为blob
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ return response.data;
|
|
|
+ } catch (error) {
|
|
|
+ console.error('Error getting tiff image (public):', error);
|
|
|
+ throw error;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取tiff图像(认证接口)
|
|
|
+ *
|
|
|
+ * @param filename tiff文件名
|
|
|
+ * @returns tiff文件 Blob
|
|
|
+ * @throws 当获取失败时抛出错误
|
|
|
+ *
|
|
|
+ * @example
|
|
|
+ * ```typescript
|
|
|
+ * const tiffBlob = await getTiffImageAuth('1.2.276.0.1000000.5.1.4.dcm.tiff');
|
|
|
+ * const blobUrl = URL.createObjectURL(tiffBlob);
|
|
|
+ * ```
|
|
|
+ */
|
|
|
+export const getTiffImageAuth = async (
|
|
|
+ filename: string
|
|
|
+): Promise<Blob> => {
|
|
|
+ try {
|
|
|
+ const response = await axiosInstance.get(
|
|
|
+ `/auth/f/tif/${filename}`,
|
|
|
+ {
|
|
|
+ responseType: 'blob', // 重要:指定响应类型为blob
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ return response.data;
|
|
|
+ } catch (error) {
|
|
|
+ console.error('Error getting tiff image (auth):', error);
|
|
|
+ throw error;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+/**
|
|
|
+ * 图像处理参数v2响应类型
|
|
|
+ */
|
|
|
+export interface GetImageProcessingParamsV2Response {
|
|
|
+ /** 响应码 */
|
|
|
+ code: string;
|
|
|
+ /** 描述信息 */
|
|
|
+ description: string;
|
|
|
+ /** 解决方案 */
|
|
|
+ solution: string;
|
|
|
+ /** 数据内容 */
|
|
|
+ data: {
|
|
|
+ /** 增益 */
|
|
|
+ contrast: number;
|
|
|
+ /** 细节 */
|
|
|
+ detail: number;
|
|
|
+ /** 动态范围 */
|
|
|
+ latitude: number;
|
|
|
+ /** 噪声模式 */
|
|
|
+ noise: number;
|
|
|
+ /** 对比度 */
|
|
|
+ ww_coef: number;
|
|
|
+ /** 亮度 */
|
|
|
+ wl_coef: number;
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取当前dcm所用的图像处理参数(v2)
|
|
|
+ *
|
|
|
+ * @param sopInstanceUid 图像实例 UID (SOP Instance UID)
|
|
|
+ * @returns 当前图像处理参数
|
|
|
+ * @throws 当获取失败时抛出错误
|
|
|
+ *
|
|
|
+ * @example
|
|
|
+ * ```typescript
|
|
|
+ * const params = await getImageProcessingParamsV2('1.2.276.0.1000000.5.1.4.701601461.19649.1749545373.668671');
|
|
|
+ * console.log('当前增益:', params.data.contrast);
|
|
|
+ * console.log('当前对比度:', params.data.ww_coef);
|
|
|
+ * ```
|
|
|
+ */
|
|
|
+export const getImageProcessingParamsV2 = async (
|
|
|
+ sopInstanceUid: string
|
|
|
+): Promise<GetImageProcessingParamsV2Response> => {
|
|
|
+ try {
|
|
|
+ const response = await axiosInstance.get<GetImageProcessingParamsV2Response>(
|
|
|
+ `/auth/image/${sopInstanceUid}/img_proc_params`
|
|
|
+ );
|
|
|
+
|
|
|
+ if (response.data.code !== '0x000000') {
|
|
|
+ throw new Error(`获取图像处理参数失败: ${response.data.description}`);
|
|
|
+ }
|
|
|
+
|
|
|
+ return response.data;
|
|
|
+ } catch (error) {
|
|
|
+ console.error('Error getting image processing params v2:', error);
|
|
|
+ throw error;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+/**
|
|
|
+ * 重建dcm请求类型
|
|
|
+ */
|
|
|
+export interface RebuildDcmRequest {
|
|
|
+ /** 增益 */
|
|
|
+ contrast: number;
|
|
|
+ /** 细节 */
|
|
|
+ detail: number;
|
|
|
+ /** 动态范围 */
|
|
|
+ latitude: number;
|
|
|
+ /** 噪声模式 */
|
|
|
+ noise: number;
|
|
|
+ /** 对比度 */
|
|
|
+ ww_coef: number;
|
|
|
+ /** 亮度 */
|
|
|
+ wl_coef: number;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 重建dcm响应类型
|
|
|
+ */
|
|
|
+export interface RebuildDcmResponse {
|
|
|
+ /** 响应码 */
|
|
|
+ code: string;
|
|
|
+ /** 描述信息 */
|
|
|
+ description: string;
|
|
|
+ /** 解决方案 */
|
|
|
+ solution: string;
|
|
|
+ /** 数据内容 */
|
|
|
+ data: Record<string, never>;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 重建dcm(保存应用增强参数后的dcm)
|
|
|
+ *
|
|
|
+ * @param sopInstanceUid 图像实例 UID (SOP Instance UID)
|
|
|
+ * @param params 图像处理参数
|
|
|
+ * @returns 重建结果
|
|
|
+ * @throws 当重建失败时抛出错误
|
|
|
+ *
|
|
|
+ * @example
|
|
|
+ * ```typescript
|
|
|
+ * await rebuildDcm('1.2.276.0.1000000.5.1.4.701601461.19649.1749545373.668671', {
|
|
|
+ * contrast: 5.0,
|
|
|
+ * detail: 8.0,
|
|
|
+ * latitude: 6.0,
|
|
|
+ * noise: 4.0,
|
|
|
+ * ww_coef: 1.2,
|
|
|
+ * wl_coef: -0.5
|
|
|
+ * });
|
|
|
+ * ```
|
|
|
+ */
|
|
|
+export const rebuildDcm = async (
|
|
|
+ sopInstanceUid: string,
|
|
|
+ params: RebuildDcmRequest
|
|
|
+): Promise<RebuildDcmResponse> => {
|
|
|
+ try {
|
|
|
+ const response = await axiosInstance.post<RebuildDcmResponse>(
|
|
|
+ `/auth/image/${sopInstanceUid}/rebuild_dcm`,
|
|
|
+ params
|
|
|
+ );
|
|
|
+
|
|
|
+ if (response.data.code !== '0x000000') {
|
|
|
+ throw new Error(`重建dcm失败: ${response.data.description}`);
|
|
|
+ }
|
|
|
+
|
|
|
+ return response.data;
|
|
|
+ } catch (error) {
|
|
|
+ console.error('Error rebuilding dcm:', error);
|
|
|
+ throw error;
|
|
|
+ }
|
|
|
+};
|