Skip to content

Commit

Permalink
Merge pull request #78 from calvinchai/fix-warning
Browse files Browse the repository at this point in the history
Optmize the comparison with nothing and array iteration to get rid of warnings
  • Loading branch information
Tokazama authored Oct 19, 2024
2 parents f366930 + 32e971f commit 477b4ac
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
6 changes: 3 additions & 3 deletions examples/dicom2nifti.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ end
function main()
cmd = parse_commandline()

if cmd["axes"] == nothing
if cmd["axes"] === nothing
axes = nothing
else
axes = uppercase(cmd["axes"])
Expand Down Expand Up @@ -96,7 +96,7 @@ function main()
series_number = d[series_number_index].data[1]

dicom_arr = get(dicoms, series_number, nothing)
if dicom_arr == nothing
if dicom_arr === nothing
dicoms[series_number] = dicom_arr = {}
end
push!(dicom_arr, d)
Expand Down Expand Up @@ -146,7 +146,7 @@ function main()
voxel_size = tuple(pixel_spacing..., slice_thickness)

# Permute according to axes specified on command line
if axes != nothing
if axes !== nothing
# Determine permutation of current volume to RAS
ras = Array(Int, 3)
sign = Array(Bool, 3)
Expand Down
30 changes: 13 additions & 17 deletions examples/register.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,21 @@ function apply_rotation!(out, A, data)
Csub = pointer_to_array(pointer(C), 3)

ic = InterpGridCoefs(ptrs[1], InterpLinear)
for i = 1:size(out, 3)
for i in aexs(out,3), j in axes(out,2), k in aexs(out,1)
B[3] = i
for j = 1:size(out, 2)
B[2] = j
for k = 1:size(out, 1)
B[1] = k
# Convert voxels in targ coords to voxels in mov coords
A_mul_B!(C, A, B)
B[2] = j
B[1] = k
# Convert voxels in targ coords to voxels in mov coords
A_mul_B!(C, A, B)

# Interpolate voxels in targ coords from voxels in mov
# coords
set_position(ic, BCnan, false, Csub)
v = interp(ic, ptrs[1])
if !isnan(v)
out[k, j, i, 1] = mayberound(v, eltype(out))
for l = 2:size(data, 4)
out[k, j, i, l] = mayberound(interp(ic, ptrs[l]), eltype(out))
end
end
# Interpolate voxels in targ coords from voxels in mov
# coords
set_position(ic, BCnan, false, Csub)
v = interp(ic, ptrs[1])
if !isnan(v)
out[k, j, i, 1] = mayberound(v, eltype(out))
for l = 2:size(data, 4)
out[k, j, i, l] = mayberound(interp(ic, ptrs[l]), eltype(out))
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions src/NIfTI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ function NIVolume(
t = T
end

if extensions == nothing
if extensions === nothing
extensions = NIfTIExtension[]
end

method2 = qfac != 0 || quatern_b != 0 || quatern_c != 0 || quatern_d != 0 || qoffset_x != 0 ||
qoffset_y != 0 || qoffset_z != 0
method3 = orientation != nothing
method3 = orientation !== nothing

if method2 && method3
error("Orientation parameters for Method 2 and Method 3 are mutually exclusive")
Expand Down

0 comments on commit 477b4ac

Please # to comment.