Skip to content

Commit

Permalink
Fixed bug in NIFTIImporter and added support for 32 bit integer images
Browse files Browse the repository at this point in the history
…#205.

Also fixed a bug with level/window setting in SlicerWindow
  • Loading branch information
smistad committed Feb 13, 2024
1 parent 629a506 commit bbc016d
Show file tree
Hide file tree
Showing 49 changed files with 267 additions and 118 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ project(FAST)

set(VERSION_MAJOR 4)
set(VERSION_MINOR 8)
set(VERSION_PATCH 0)
set(VERSION_PATCH 1)
set(VERSION_SO 4) # SO version, should be incremented by 1 every time the existing API changes
set(FAST_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")

Expand Down
14 changes: 8 additions & 6 deletions doc/pages/Download-stats.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Download Statistics {#download-stats}
==================================

PyPi (pip) Downloads
--------------------

* ![](https://shields.io/pypi/dd/pyfast)
* ![](https://shields.io/pypi/dw/pyfast)
* ![](https://shields.io/pypi/dm/pyfast)


GitHub Downloads
--------------------

Expand All @@ -23,9 +31,3 @@ GitHub Downloads
* ![](https://shields.io/github/downloads/smistad/fast/v1.2.0/total)
* ![](https://shields.io/github/downloads/smistad/fast/v1.1.0/total)
* ![](https://shields.io/github/downloads/smistad/fast/v1.0.0/total)

PyPi (pip) Downloads
--------------------
* ![](https://shields.io/pypi/dd/pyfast)
* ![](https://shields.io/pypi/dw/pyfast)
* ![](https://shields.io/pypi/dm/pyfast)
6 changes: 3 additions & 3 deletions source/FAST/Algorithms/ApplyColormap/ApplyColormap.cl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ float4 readImageAsFloat2D(__read_only image2d_t image, sampler_t sampler, int2 p
int dataType = get_image_channel_data_type(image);
if(dataType == CLK_FLOAT || dataType == CLK_SNORM_INT16 || dataType == CLK_UNORM_INT16) {
return read_imagef(image, sampler, position);
} else if(dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT8) {
} else if(dataType == CLK_SIGNED_INT8 || dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT32) {
return convert_float4(read_imagei(image, sampler, position));
} else {
return convert_float4(read_imageui(image, sampler, position));
Expand All @@ -16,7 +16,7 @@ void writeImageAsFloat42D(__write_only image2d_t image, int2 position, float4 va
int dataType = get_image_channel_data_type(image);
if(dataType == CLK_FLOAT || dataType == CLK_SNORM_INT16 || dataType == CLK_UNORM_INT16) {
write_imagef(image, position, value);
} else if(dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT8) {
} else if(dataType == CLK_SIGNED_INT8 || dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT32) {
write_imagei(image, position, convert_int4(round(value)));
} else {
write_imageui(image, position, convert_uint4(round(value)));
Expand All @@ -28,7 +28,7 @@ void writeImageAsFloat2D(__write_only image2d_t image, int2 position, float valu
int dataType = get_image_channel_data_type(image);
if(dataType == CLK_FLOAT || dataType == CLK_SNORM_INT16 || dataType == CLK_UNORM_INT16) {
write_imagef(image, position, value);
} else if(dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT8) {
} else if(dataType == CLK_SIGNED_INT8 || dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT32) {
write_imagei(image, position, convert_int4(round(value)));
} else {
write_imageui(image, position, convert_uint4(round(value)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ float getIntensity(__read_only image2d_t image, int2 pos) {
int dataType = get_image_channel_data_type(image);
if(dataType == CLK_FLOAT) {
value = read_imagef(image, sampler, pos).x;
} else if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16) {
} else if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16 || dataType == CLK_UNSIGNED_INT32) {
value = read_imageui(image, sampler, pos).x;
} else {
value = read_imagei(image, sampler, pos).x;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ float getIntensity(__read_only image3d_t image, int4 pos) {
int dataType = get_image_channel_data_type(image);
if(dataType == CLK_FLOAT) {
value = read_imagef(image, sampler, pos).x;
} else if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16) {
} else if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16 || dataType == CLK_UNSIGNED_INT32) {
value = read_imageui(image, sampler, pos).x;
} else {
value = read_imagei(image, sampler, pos).x;
Expand Down
2 changes: 1 addition & 1 deletion source/FAST/Algorithms/BlockMatching/BlockMatching.cl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ float getPixelAsFloat(__read_only image2d_t image, int2 pos) {
int dataType = get_image_channel_data_type(image);
if(dataType == CLK_FLOAT) {
value = read_imagef(image, sampler, pos).x;
} else if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16) {
} else if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16 || dataType == CLK_UNSIGNED_INT32) {
value = read_imageui(image, sampler, pos).x;
} else {
value = read_imagei(image, sampler, pos).x;
Expand Down
2 changes: 1 addition & 1 deletion source/FAST/Algorithms/Color/ColorToGrayscale.cl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ __kernel void convert(
) {
const int2 pos = {get_global_id(0), get_global_id(1)};
int dataType = get_image_channel_data_type(input);
if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16) {
if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16 || dataType == CLK_UNSIGNED_INT32) {
uint4 value = read_imageui(input, sampler, pos);
uint average = round(((float)(value.x + value.y + value.z))/3.0f);
write_imageui(output, pos, average);
Expand Down
2 changes: 1 addition & 1 deletion source/FAST/Algorithms/Color/GrayscaleToColor.cl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ __kernel void convert(
) {
const int2 pos = {get_global_id(0), get_global_id(1)};
int dataType = get_image_channel_data_type(input);
if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16) {
if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16 || dataType == CLK_UNSIGNED_INT32) {
uint value = read_imageui(input, sampler, pos).x;
write_imageui(output, pos, (uint4)(value, value, value, 255));
} else if(dataType == CLK_FLOAT) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ __kernel void gaussianSmoothing(
const int2 offset = {x,y};
if(dataType == CLK_FLOAT) {
sum += mask[x+halfSize+(y+halfSize)*maskSize]*read_imagef(input, sampler, pos+offset).x;
} else if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16) {
} else if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16 || dataType == CLK_UNSIGNED_INT32) {
sum += mask[x+halfSize+(y+halfSize)*maskSize]*read_imageui(input, sampler, pos+offset).x;
} else {
sum += mask[x+halfSize+(y+halfSize)*maskSize]*read_imagei(input, sampler, pos+offset).x;
Expand All @@ -27,7 +27,7 @@ __kernel void gaussianSmoothing(
int outputDataType = get_image_channel_data_type(output);
if(outputDataType == CLK_FLOAT) {
write_imagef(output, pos, sum);
} else if(outputDataType == CLK_UNSIGNED_INT8 || outputDataType == CLK_UNSIGNED_INT16) {
} else if(outputDataType == CLK_UNSIGNED_INT8 || outputDataType == CLK_UNSIGNED_INT16 || outputDataType == CLK_UNSIGNED_INT32) {
write_imageui(output, pos, round(sum));
} else {
write_imagei(output, pos, round(sum));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ __kernel void gaussianSmoothing(
const uchar maskOffset = halfSize + i;
if(dataType == CLK_FLOAT) {
sum += mask[maskOffset]*read_imagef(input, sampler, pos+offset).x;
} else if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16) {
} else if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16 || dataType == CLK_UNSIGNED_INT32) {
sum += mask[maskOffset]*read_imageui(input, sampler, pos+offset).x;
} else {
sum += mask[maskOffset]*read_imagei(input, sampler, pos+offset).x;
Expand All @@ -36,7 +36,7 @@ __kernel void gaussianSmoothing(
int outputDataType = get_image_channel_data_type(output);
if(outputDataType == CLK_FLOAT) {
write_imagef(output, pos, sum);
} else if(outputDataType == CLK_UNSIGNED_INT8 || outputDataType == CLK_UNSIGNED_INT16) {
} else if(outputDataType == CLK_UNSIGNED_INT8 || outputDataType == CLK_UNSIGNED_INT16 || outputDataType == CLK_UNSIGNED_INT32) {
write_imageui(output, pos, round(sum));
} else {
write_imagei(output, pos, round(sum));
Expand All @@ -63,7 +63,7 @@ __kernel void gaussianSmoothing(
const uint maskOffset = x+halfSize+(y+halfSize)*maskSize+(z+halfSize)*maskSize*maskSize;
if(dataType == CLK_FLOAT) {
sum += mask[maskOffset]*read_imagef(input, sampler, pos+offset).x;
} else if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16) {
} else if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16 || dataType == CLK_UNSIGNED_INT32) {
sum += mask[maskOffset]*read_imageui(input, sampler, pos+offset).x;
} else {
sum += mask[maskOffset]*read_imagei(input, sampler, pos+offset).x;
Expand Down
6 changes: 3 additions & 3 deletions source/FAST/Algorithms/ImageAdd/ImageAdd.cl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ float4 readImageAsFloat2D(__read_only image2d_t image, sampler_t sampler, int2 p
int dataType = get_image_channel_data_type(image);
if(dataType == CLK_FLOAT || dataType == CLK_SNORM_INT16 || dataType == CLK_UNORM_INT16) {
return read_imagef(image, sampler, position);
} else if(dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT8) {
} else if(dataType == CLK_SIGNED_INT8 || dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT32) {
return convert_float4(read_imagei(image, sampler, position));
} else {
return convert_float4(read_imageui(image, sampler, position));
Expand All @@ -16,7 +16,7 @@ void writeImageAsFloat2D(__write_only image2d_t image, int2 position, float4 val
int dataType = get_image_channel_data_type(image);
if(dataType == CLK_FLOAT || dataType == CLK_SNORM_INT16 || dataType == CLK_UNORM_INT16) {
write_imagef(image, position, value);
} else if(dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT8) {
} else if(dataType == CLK_SIGNED_INT8 || dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT32) {
write_imagei(image, position, convert_int4(round(value)));
} else {
write_imageui(image, position, convert_uint4(round(value)));
Expand All @@ -27,7 +27,7 @@ float4 readImageAsFloat3D(__read_only image3d_t image, sampler_t sampler, int4 p
int dataType = get_image_channel_data_type(image);
if(dataType == CLK_FLOAT || dataType == CLK_SNORM_INT16 || dataType == CLK_UNORM_INT16) {
return read_imagef(image, sampler, position);
} else if(dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT8) {
} else if(dataType == CLK_SIGNED_INT8 || dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT32) {
return convert_float4(read_imagei(image, sampler, position));
} else {
return convert_float4(read_imageui(image, sampler, position));
Expand Down
4 changes: 2 additions & 2 deletions source/FAST/Algorithms/ImageCaster/ImageCaster.cl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ float4 readImageAsFloat2D(__read_only image2d_t image, sampler_t sampler, int2 p
int dataType = get_image_channel_data_type(image);
if(dataType == CLK_FLOAT || dataType == CLK_SNORM_INT16 || dataType == CLK_UNORM_INT16) {
return read_imagef(image, sampler, position);
} else if(dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT8) {
} else if(dataType == CLK_SIGNED_INT8 || dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT32) {
return convert_float4(read_imagei(image, sampler, position));
} else {
return convert_float4(read_imageui(image, sampler, position));
Expand All @@ -15,7 +15,7 @@ void writeImageAsFloat2D(__write_only image2d_t image, int2 position, float4 val
int dataType = get_image_channel_data_type(image);
if(dataType == CLK_FLOAT || dataType == CLK_SNORM_INT16 || dataType == CLK_UNORM_INT16) {
write_imagef(image, position, value);
} else if(dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT8) {
} else if(dataType == CLK_SIGNED_INT8 || dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT32) {
write_imagei(image, position, convert_int4(round(value)));
} else {
write_imageui(image, position, convert_uint4(round(value)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ __kernel void channelConvert2D(
}

write_imagef(output, pos, (float4)(result[0], result[1], result[2], result[3]));
} else if(type == CLK_UNSIGNED_INT8 || type == CLK_UNSIGNED_INT16) {
} else if(type == CLK_UNSIGNED_INT8 || type == CLK_UNSIGNED_INT16 || type == CLK_UNSIGNED_INT32) {
uint4 tmp = read_imageui(input, sampler, pos);
uint* pixel = (uint*)&tmp;
uint result[4];
Expand Down Expand Up @@ -91,7 +91,7 @@ __kernel void channelConvert3D(
}

write_imagef(output, pos, (float4)(result[0], result[1], result[2], result[3]));
} else if(type == CLK_UNSIGNED_INT8 || type == CLK_UNSIGNED_INT16) {
} else if(type == CLK_UNSIGNED_INT8 || type == CLK_UNSIGNED_INT16 || type == CLK_UNSIGNED_INT32) {
uint4 tmp = read_imageui(input, sampler, pos);
uint* pixel = (uint*)&tmp;
uint result[4];
Expand Down
2 changes: 1 addition & 1 deletion source/FAST/Algorithms/ImageFlipper/ImageFlipper2D.cl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ __kernel void flip2D(
int dataType = get_image_channel_data_type(input);
if(dataType == CLK_FLOAT) {
write_imagef(output, targetPos, read_imagef(input, sampler, pos));
} else if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16) {
} else if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16 || dataType == CLK_UNSIGNED_INT32) {
write_imageui(output, targetPos, read_imageui(input, sampler, pos));
} else {
write_imagei(output, targetPos, read_imagei(input, sampler, pos));
Expand Down
2 changes: 1 addition & 1 deletion source/FAST/Algorithms/ImageFlipper/ImageFlipper3D.cl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ __kernel void flip3D(
output[(targetPos.x + targetPos.y*size.x + targetPos.z*size.x*size.y)*channels+2] = value.z;
if(channels > 3)
output[(targetPos.x + targetPos.y*size.x + targetPos.z*size.x*size.y)*channels+3] = value.w;
} else if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16) {
} else if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16 || dataType == CLK_UNSIGNED_INT32) {
uint4 value = read_imageui(input, sampler, posInput);
output[(targetPos.x + targetPos.y*size.x + targetPos.z*size.x*size.y)*channels] = value.x;
if(channels > 1)
Expand Down
4 changes: 2 additions & 2 deletions source/FAST/Algorithms/ImageGradient/ImageGradient.cl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ float readImageAsFloat2D(__read_only image2d_t image, sampler_t sampler, int2 po
int dataType = get_image_channel_data_type(image);
if(dataType == CLK_FLOAT || dataType == CLK_SNORM_INT16 || dataType == CLK_UNORM_INT16) {
return read_imagef(image, sampler, position).x;
} else if(dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT8) {
} else if(dataType == CLK_SIGNED_INT8 || dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT32) {
return (float)read_imagei(image, sampler, position).x;
} else {
return (float)read_imageui(image, sampler, position).x;
Expand All @@ -16,7 +16,7 @@ float readImageAsFloat3D(__read_only image3d_t image, sampler_t sampler, int4 po
int dataType = get_image_channel_data_type(image);
if(dataType == CLK_FLOAT || dataType == CLK_SNORM_INT16 || dataType == CLK_UNORM_INT16) {
return read_imagef(image, sampler, position).x;
} else if(dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT8) {
} else if(dataType == CLK_SIGNED_INT8 || dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT32) {
return (float)read_imagei(image, sampler, position).x;
} else {
return (float)read_imageui(image, sampler, position).x;
Expand Down
2 changes: 1 addition & 1 deletion source/FAST/Algorithms/ImageInverter/ImageInverter.cl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ __kernel void invert3D(
float4 value;
if(dataType == CLK_FLOAT) {
value = read_imagef(input, sampler, pos);
} else if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16) {
} else if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16 || dataType == CLK_UNSIGNED_INT32) {
value = convert_float4(read_imageui(input, sampler, pos));
} else {
value = convert_float4(read_imagei(input, sampler, pos));
Expand Down
6 changes: 3 additions & 3 deletions source/FAST/Algorithms/ImageMultiply/ImageMultiply.cl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ float4 readImageAsFloat2D(__read_only image2d_t image, sampler_t sampler, int2 p
int dataType = get_image_channel_data_type(image);
if(dataType == CLK_FLOAT || dataType == CLK_SNORM_INT16 || dataType == CLK_UNORM_INT16) {
return read_imagef(image, sampler, position);
} else if(dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT8) {
} else if(dataType == CLK_SIGNED_INT8 || dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT32) {
return convert_float4(read_imagei(image, sampler, position));
} else {
return convert_float4(read_imageui(image, sampler, position));
Expand All @@ -16,7 +16,7 @@ void writeImageAsFloat2D(__write_only image2d_t image, int2 position, float4 val
int dataType = get_image_channel_data_type(image);
if(dataType == CLK_FLOAT || dataType == CLK_SNORM_INT16 || dataType == CLK_UNORM_INT16) {
write_imagef(image, position, value);
} else if(dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT8) {
} else if(dataType == CLK_SIGNED_INT8 || dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT32) {
write_imagei(image, position, convert_int4(round(value)));
} else {
write_imageui(image, position, convert_uint4(round(value)));
Expand All @@ -27,7 +27,7 @@ float4 readImageAsFloat3D(__read_only image3d_t image, sampler_t sampler, int4 p
int dataType = get_image_channel_data_type(image);
if(dataType == CLK_FLOAT || dataType == CLK_SNORM_INT16 || dataType == CLK_UNORM_INT16) {
return read_imagef(image, sampler, position);
} else if(dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT8) {
} else if(dataType == CLK_SIGNED_INT8 || dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT32) {
return convert_float4(read_imagei(image, sampler, position));
} else {
return convert_float4(read_imageui(image, sampler, position));
Expand Down
2 changes: 1 addition & 1 deletion source/FAST/Algorithms/ImagePatch/PatchStitcher2D.cl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ __kernel void applyPatch2D(
int2 offset = {startX - patchOverlapX, startY - patchOverlapY};
if(dataType == CLK_FLOAT) {
write_imagef(image, pos, read_imagef(patch, sampler, pos - offset));
} else if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16) {
} else if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16 || dataType == CLK_UNSIGNED_INT32) {
write_imageui(image, pos, read_imageui(patch, sampler, pos - offset));
} else {
write_imagei(image, pos, read_imagei(patch, sampler, pos - offset));
Expand Down
Loading

0 comments on commit bbc016d

Please sign in to comment.