Skip to content

Instantly share code, notes, and snippets.

Avatar

Mark Kittisopikul mkitti

View GitHub Profile
@mkitti
mkitti / h5py_zstd_numcodecs.py
Created Feb 17, 2022
Reading raw ZStandard (Zstd) chunks from a HDF5 file via numcodecs
View h5py_zstd_numcodecs.py
import h5py
import hdf5plugin
import numcodecs
import numpy as np
# Create data
A = np.random.randint(1024, size=(1024, 1024, 128))
print("Data as created:")
print(A[1, 1, :10])
View 06_Array_Operations_with_Julia.jl
# Implementing cell 6 of https://github.com/barbagroup/CFDPython/blob/master/lessons/06_Array_Operations_with_NumPy.ipynb
# Inspried during stream of https://www.twitch.tv/brainrpg
function main()
nx = 81
ny = 81
nt = 100
c = 1
dx = 2 / (nx - 1)
dy = 2 / (ny - 1)
@mkitti
mkitti / open_ims_from_julia.ipynb
Created Nov 4, 2021
open_ims_from_julia.ipynb
View open_ims_from_julia.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mkitti
mkitti / Downsampling.jl
Last active Aug 1, 2021
Code to downsample
View Downsampling.jl
module Downsampling
using TiledIteration, BenchmarkTools
I = rand(UInt16, 10000, 10000);
D = zeros(size(I)2...);
function avgNxN!(I, D, ::Val{N}) where N
for c = 1:size(D,2), bc = 1-N:0, r = 1:size(D,1), br = 1-N:0
@inbounds D[r,c] += I[r*N+br, c*N+bc]/N/N
end
@mkitti
mkitti / WinApi.jl
Created Apr 26, 2021
WinApi.isfile_casesensitive
View WinApi.jl
module WinApi
const MAX_PATH = 260
const FILE_ATTRIBUTE_DIRECTORY = 0x10
const INVALID_HANDLE_VALUE = -1
struct FileTime
dwLowDateTime::UInt32
dwHighDateTime::UInt32
FileTime() = new(0,0)
@mkitti
mkitti / rational_from_string.jl
Created Apr 13, 2021
Convert a decimal representation to a Rational in Julia
View rational_from_string.jl
# Via Fredrik Ekre
# https://julialang.zulipchat.com/#narrow/stream/274208-helpdesk-.28published.29/topic/String.20macro.20for.20rationals.3F
function rational_from_string(s)
x, y = split(s, '.')
a = parse(Int, x)
b = parse(Int, y)
return a + b // 10^length(y)
end
macro rational_str(s)
View using_at_debug.jl
julia> a = 10
10
julia> @info "Macros are awesome" a
┌ Info: Macros are awesome
└ a = 10
julia> @debug "How awesome?" a
julia> using Logging; global_logger( ConsoleLogger(stderr, Logging.Debug) );
View LargeSparseArrays.jl
module LargeSparseArrays
import Base: size, getindex, setindex!
export LargeSparseArray
struct LargeSparseArray{T,N} <: AbstractArray{T,N}
d::Dict{CartesianIndex{N},T}
dims::NTuple{N,AbstractUnitRange{Int}}
function LargeSparseArray{T}(dims::Int...) where T
dim_ranges = Base.OneTo.(dims)
View rapidSquareROITool.ijm
//rapidSquareROITool.ijm
//Creates six tools that allows you to quickly add either 64x64 or 32x32 square ROIs
//
// Mark Kittisopikul, September 11th, 2018
// Goldman Lab
// Northwestern University
//
// Tools:
// 1. Create a 64x64 px square ROI at the location clicked and add to ROI manager
// 2. Create a 32x32 px square ROI at the location clicked and add to ROI manager
View filtering_teaching.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.