Skip to content

Instantly share code, notes, and snippets.

View mkitti's full-sized avatar

Mark Kittisopikul mkitti

View GitHub Profile
@mkitti
mkitti / read_teaching.ipynb
Last active May 18, 2020 23:56
Basic Image Loading in Python
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mkitti
mkitti / filtering_teaching.ipynb
Last active May 28, 2020 18:27
Teaching Filtering
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
//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
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)
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) );
@mkitti
mkitti / rational_from_string.jl
Created April 13, 2021 17:01
Convert a decimal representation to a Rational in Julia
# 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)
@mkitti
mkitti / WinApi.jl
Created April 26, 2021 23:31
WinApi.isfile_casesensitive
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 / Downsampling.jl
Last active August 1, 2021 08:39
Code to downsample
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 / open_ims_from_julia.ipynb
Created November 4, 2021 21:47
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.
# 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)