Skip to content

Instantly share code, notes, and snippets.

View mcdlee's full-sized avatar

Sin-Di Lee mcdlee

View GitHub Profile
@mcdlee
mcdlee / cost_matrix.ipynb
Created July 6, 2023 04:46
Loss matrix of EMD in Python optimal transports
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
def lines2intersectionTuple(L1, L2):
# intersection of xcos(theta)+ysin(theta)=D, input as (theta, D) tuple
# the unit of theta is degree
theta1 = np.deg2rad(L1[0])
theta2 = np.deg2rad(L2[0])
D1 = L1[1]
D2 = L2[1]
y = np.round((D1/np.cos(theta1) - D2/np.cos(theta2))/(np.tan(theta1)-np.tan(theta2)))
x = np.round((D1/np.cos(theta1) - y*np.tan(theta1)))
@mcdlee
mcdlee / SobelHough.ipynb
Created April 18, 2022 02:31
Sobel and Hough
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mcdlee
mcdlee / functions.R
Last active August 26, 2021 09:45
GATE singles file processing
filtering <- function(list, xFOV = 533, yFOV = 387, energy="All"){
# unit of FOV is mm
# energy windows including "Tc", "Ga", "I131"
require(data.table)
require(dplyr)
require(magrittr)
require(tidyr)
require(Matrix)
FOV <- subset(list, (V12 <= xFOV/2 & V12 >= -xFOV/2 & V14 <= yFOV/2 & V14 >= -yFOV/2))
pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org <modulename>
@mcdlee
mcdlee / AW_repeat.ahk
Created October 22, 2020 10:02
AW_repeat.ahk
^j::RepeatClick() ;請按 ctrl-j
RepeatClick() {
InputBox, repeat, Repeat, How many times do you want to repeat?
Loop, %repeat%
{
Send {F3}
Sleep, 500
Click, 100, 300 ;不會妨礙操作的座標
@mcdlee
mcdlee / global.R
Created October 13, 2020 02:29
RadExp
library(shiny)
isotopeTable <- read.csv("isotope.csv")
isotopeList <- isotopeTable$isotope
generateActivityTable <- function(Bq){
Unit <- c("Bq", "kBq", "MBq", "mCi", "Ci")
Activity <- c(Bq, Bq/1E3, Bq/1E6, Bq/3.7E7, Bq/3.7E10)
table <- data.frame(Unit, Activity)
@mcdlee
mcdlee / main.py
Created July 25, 2020 02:59
PyRadiomics to Pandas DataFrame
import radiomics
import six
from radiomics import featureextractor
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
extractor = featureextractor.RadiomicsFeatureExtractor()
def feature2pd(image, mask, index):
@mcdlee
mcdlee / u_and_n.ipynb
Last active June 23, 2020 02:29
Using PyTorch to classify my writing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.