@@ -27,7 +27,7 @@ interface DimFactors {
2727function dimScaleFactors (
2828 dims : string [ ] ,
2929 scaleFactor : Record < string , number > | number ,
30- previousDimFactors : DimFactors
30+ previousDimFactors : DimFactors ,
3131) : DimFactors {
3232 const dimFactors : DimFactors = { } ;
3333
@@ -58,7 +58,7 @@ function dimScaleFactors(
5858function updatePreviousDimFactors (
5959 scaleFactor : Record < string , number > | number ,
6060 spatialDims : string [ ] ,
61- previousDimFactors : DimFactors
61+ previousDimFactors : DimFactors ,
6262) : DimFactors {
6363 const updated : DimFactors = { ...previousDimFactors } ;
6464
@@ -83,7 +83,7 @@ function updatePreviousDimFactors(
8383function nextScaleMetadata (
8484 image : NgffImage ,
8585 dimFactors : DimFactors ,
86- spatialDims : string [ ]
86+ spatialDims : string [ ] ,
8787) : [ Record < string , number > , Record < string , number > ] {
8888 const translation : Record < string , number > = { } ;
8989 const scale : Record < string , number > = { } ;
@@ -92,8 +92,8 @@ function nextScaleMetadata(
9292 if ( spatialDims . includes ( dim ) ) {
9393 const factor = dimFactors [ dim ] ;
9494 scale [ dim ] = image . scale [ dim ] * factor ;
95- translation [ dim ] =
96- image . translation [ dim ] + 0.5 * ( factor - 1 ) * image . scale [ dim ] ;
95+ translation [ dim ] = image . translation [ dim ] +
96+ 0.5 * ( factor - 1 ) * image . scale [ dim ] ;
9797 } else {
9898 // Only copy non-spatial dimensions if they exist in the source
9999 if ( dim in image . scale ) {
@@ -135,7 +135,7 @@ function computeSigma(shrinkFactors: number[]): number[] {
135135async function zarrToItkImage (
136136 array : zarr . Array < zarr . DataType , zarr . Readable > ,
137137 dims : string [ ] ,
138- isVector = false
138+ isVector = false ,
139139) : Promise < Image > {
140140 // Read the full array data
141141 const result = await zarr . get ( array ) ;
@@ -178,7 +178,7 @@ async function zarrToItkImage(
178178 result . data ,
179179 result . shape ,
180180 permutation ,
181- getItkComponentType ( result . data )
181+ getItkComponentType ( result . data ) ,
182182 ) ;
183183 } else {
184184 // "c" already at end or not present, just copy data
@@ -217,7 +217,7 @@ async function zarrToItkImage(
217217 * Copy typed array to appropriate type
218218 */
219219function copyTypedArray (
220- data : unknown
220+ data : unknown ,
221221) :
222222 | Float32Array
223223 | Float64Array
@@ -272,7 +272,7 @@ function transposeArray(
272272 | "uint64"
273273 | "int64"
274274 | "float32"
275- | "float64"
275+ | "float64" ,
276276) :
277277 | Float32Array
278278 | Float64Array
@@ -384,7 +384,7 @@ function transposeArray(
384384 * Get ITK component type from typed array
385385 */
386386function getItkComponentType (
387- data : unknown
387+ data : unknown ,
388388) :
389389 | "uint8"
390390 | "int8"
@@ -425,7 +425,7 @@ function createIdentityMatrix(dimension: number): Float64Array {
425425async function itkImageToZarr (
426426 itkImage : Image ,
427427 path : string ,
428- chunkShape : number [ ]
428+ chunkShape : number [ ] ,
429429) : Promise < zarr . Array < zarr . DataType , zarr . Readable > > {
430430 // Use in-memory store
431431 const store : Map < string , Uint8Array > = new Map ( ) ;
@@ -493,7 +493,7 @@ async function downsampleChannelFirst(
493493 image : NgffImage ,
494494 dimFactors : DimFactors ,
495495 spatialDims : string [ ] ,
496- smoothing : "gaussian" | "bin_shrink" | "label_image"
496+ smoothing : "gaussian" | "bin_shrink" | "label_image" ,
497497) : Promise < NgffImage > {
498498 // Get the channel index and count
499499 const cIndex = image . dims . indexOf ( "c" ) ;
@@ -598,7 +598,7 @@ async function downsampleChannelFirst(
598598 const downsampledArray = await itkImageToZarr (
599599 downsampled ,
600600 "downsampled_channel" ,
601- downsampledChunkShape
601+ downsampledChunkShape ,
602602 ) ;
603603 downsampledChannels . push ( downsampledArray ) ;
604604 }
@@ -607,14 +607,14 @@ async function downsampleChannelFirst(
607607 const combinedArray = await combineChannels (
608608 downsampledChannels ,
609609 cIndex ,
610- image . dims
610+ image . dims ,
611611 ) ;
612612
613613 // Compute new metadata
614614 const [ translation , scale ] = nextScaleMetadata (
615615 image ,
616616 dimFactors ,
617- spatialDims
617+ spatialDims ,
618618 ) ;
619619
620620 return new NgffImage ( {
@@ -634,7 +634,7 @@ async function downsampleChannelFirst(
634634function extractChannel (
635635 result : { data : unknown ; shape : number [ ] } ,
636636 cIndex : number ,
637- channelIdx : number
637+ channelIdx : number ,
638638) :
639639 | Float32Array
640640 | Float64Array
@@ -662,7 +662,7 @@ function extractChannel(
662662 // Calculate output size (all dims except channel)
663663 const outputSize = shape . reduce (
664664 ( acc , s , i ) => ( i === cIndex ? acc : acc * s ) ,
665- 1
665+ 1 ,
666666 ) ;
667667
668668 let output :
@@ -737,7 +737,7 @@ function extractChannel(
737737async function combineChannels (
738738 channels : zarr . Array < zarr . DataType , zarr . Readable > [ ] ,
739739 cIndex : number ,
740- _originalDims : string [ ]
740+ _originalDims : string [ ] ,
741741) : Promise < zarr . Array < zarr . DataType , zarr . Readable > > {
742742 // Read all channel data
743743 const channelData = await Promise . all ( channels . map ( ( c ) => zarr . get ( c ) ) ) ;
@@ -844,20 +844,20 @@ async function combineChannels(
844844async function downsampleGaussian (
845845 image : NgffImage ,
846846 dimFactors : DimFactors ,
847- spatialDims : string [ ]
847+ spatialDims : string [ ] ,
848848) : Promise < NgffImage > {
849849 const cIndex = image . dims . indexOf ( "c" ) ;
850850 const isVector = cIndex === image . dims . length - 1 ;
851- const isChannelFirst =
852- cIndex !== - 1 && cIndex < image . dims . length - 1 && ! isVector ;
851+ const isChannelFirst = cIndex !== - 1 && cIndex < image . dims . length - 1 &&
852+ ! isVector ;
853853
854854 // If channel is first (before spatial dims), process each channel separately
855855 if ( isChannelFirst ) {
856856 return await downsampleChannelFirst (
857857 image ,
858858 dimFactors ,
859859 spatialDims ,
860- "gaussian"
860+ "gaussian" ,
861861 ) ;
862862 }
863863
@@ -896,7 +896,7 @@ async function downsampleGaussian(
896896 const [ translation , scale ] = nextScaleMetadata (
897897 image ,
898898 dimFactors ,
899- spatialDims
899+ spatialDims ,
900900 ) ;
901901
902902 // Convert back to zarr array
@@ -920,20 +920,20 @@ async function downsampleGaussian(
920920async function downsampleBinShrinkImpl (
921921 image : NgffImage ,
922922 dimFactors : DimFactors ,
923- spatialDims : string [ ]
923+ spatialDims : string [ ] ,
924924) : Promise < NgffImage > {
925925 const cIndex = image . dims . indexOf ( "c" ) ;
926926 const isVector = cIndex === image . dims . length - 1 ;
927- const isChannelFirst =
928- cIndex !== - 1 && cIndex < image . dims . length - 1 && ! isVector ;
927+ const isChannelFirst = cIndex !== - 1 && cIndex < image . dims . length - 1 &&
928+ ! isVector ;
929929
930930 // If channel is first (before spatial dims), process each channel separately
931931 if ( isChannelFirst ) {
932932 return await downsampleChannelFirst (
933933 image ,
934934 dimFactors ,
935935 spatialDims ,
936- "bin_shrink"
936+ "bin_shrink" ,
937937 ) ;
938938 }
939939
@@ -963,7 +963,7 @@ async function downsampleBinShrinkImpl(
963963 const [ translation , scale ] = nextScaleMetadata (
964964 image ,
965965 dimFactors ,
966- spatialDims
966+ spatialDims ,
967967 ) ;
968968
969969 // Convert back to zarr array
@@ -987,20 +987,20 @@ async function downsampleBinShrinkImpl(
987987async function downsampleLabelImageImpl (
988988 image : NgffImage ,
989989 dimFactors : DimFactors ,
990- spatialDims : string [ ]
990+ spatialDims : string [ ] ,
991991) : Promise < NgffImage > {
992992 const cIndex = image . dims . indexOf ( "c" ) ;
993993 const isVector = cIndex === image . dims . length - 1 ;
994- const isChannelFirst =
995- cIndex !== - 1 && cIndex < image . dims . length - 1 && ! isVector ;
994+ const isChannelFirst = cIndex !== - 1 && cIndex < image . dims . length - 1 &&
995+ ! isVector ;
996996
997997 // If channel is first (before spatial dims), process each channel separately
998998 if ( isChannelFirst ) {
999999 return await downsampleChannelFirst (
10001000 image ,
10011001 dimFactors ,
10021002 spatialDims ,
1003- "label_image"
1003+ "label_image" ,
10041004 ) ;
10051005 }
10061006
@@ -1039,7 +1039,7 @@ async function downsampleLabelImageImpl(
10391039 const [ translation , scale ] = nextScaleMetadata (
10401040 image ,
10411041 dimFactors ,
1042- spatialDims
1042+ spatialDims ,
10431043 ) ;
10441044
10451045 // Convert back to zarr array
@@ -1063,7 +1063,7 @@ async function downsampleLabelImageImpl(
10631063export async function downsampleItkWasm (
10641064 ngffImage : NgffImage ,
10651065 scaleFactors : ( Record < string , number > | number ) [ ] ,
1066- smoothing : "gaussian" | "bin_shrink" | "label_image"
1066+ smoothing : "gaussian" | "bin_shrink" | "label_image" ,
10671067) : Promise < NgffImage [ ] > {
10681068 const multiscales : NgffImage [ ] = [ ngffImage ] ;
10691069 let previousImage = ngffImage ;
@@ -1080,27 +1080,27 @@ export async function downsampleItkWasm(
10801080 previousDimFactors = updatePreviousDimFactors (
10811081 scaleFactor ,
10821082 spatialDims ,
1083- previousDimFactors
1083+ previousDimFactors ,
10841084 ) ;
10851085
10861086 let downsampled : NgffImage ;
10871087 if ( smoothing === "gaussian" ) {
10881088 downsampled = await downsampleGaussian (
10891089 previousImage ,
10901090 dimFactors ,
1091- spatialDims
1091+ spatialDims ,
10921092 ) ;
10931093 } else if ( smoothing === "bin_shrink" ) {
10941094 downsampled = await downsampleBinShrinkImpl (
10951095 previousImage ,
10961096 dimFactors ,
1097- spatialDims
1097+ spatialDims ,
10981098 ) ;
10991099 } else if ( smoothing === "label_image" ) {
11001100 downsampled = await downsampleLabelImageImpl (
11011101 previousImage ,
11021102 dimFactors ,
1103- spatialDims
1103+ spatialDims ,
11041104 ) ;
11051105 } else {
11061106 throw new Error ( `Unknown smoothing method: ${ smoothing } ` ) ;
0 commit comments