Skip to content

Instantly share code, notes, and snippets.

View nikitinvv's full-sized avatar

Viktor Nikitin nikitinvv

  • Argonne National Laboratory
View GitHub Profile
import numpy as np
import matplotlib.pyplot as plt
PLANCK_CONSTANT = 4.135667696e-18 # [keV*s]
SPEED_OF_LIGHT = 299792458 # [m/s]
n = 1024 # 1d signal sizie
ns = 64+64
voxelsize = 2*10e-9 # object voxel size
energy = 33.35 # [keV] xray energy
wavelength = PLANCK_CONSTANT * SPEED_OF_LIGHT / energy
import numpy
def gen_interlaced_theta_W():
numproj = 1440#1800-360
prime = 2
nProj_per_rot = 360
pst = 0
pend = 360
seq = []
i = 0
# syntax: python record_screen.py <output_file_name.avi> <fps> <monitor_id>
# example: python record_screen.py /local/test.avi 20 1
# on user2bmb@arcturus
# conda activate screenrecording
# (screenrecording) user2bmb@arcturus ~/vnikitin $python record_screen.py /local/test.avi 20 3
from mss import mss
from PIL import Image
import cv2
import time
# real-time visualization of numpy arrays in ImageJ
######################################################################################
# Installation:
# 1. conda create -n pyimagej -c conda-forge pyimagej openjdk=8
# 2. conda activate pyimagej
#######################################################################################
import imagej
import numpy as np
# Storage performance test with reading/writing a stack of tiff files
# Necessary python packages: tiffile, threading, numpy
# Syntax:
# python test_storage.py <data size in each dimension> <number of threads> <path to store data>
# Example:
# python test_storage.py 1024 8 /data/tmp/tiff_stack/
import numpy as np
import sys
import h5py
import cupy as cp # subpixel shifts on gpu
#import numpy as cp # subpixel shifts on cpu
## usage
### python merge_helical.py /data/helical/Coal_NaBr_075.h5 0.062480474851608875 3201
### where 0.062480474851608875 is shift in pixels between two projections
### 3201 - number of angles per 360 deg interval (<360 if only 1 rotation)
# open numpy array in imagej
######################################################################################
# Installation:
# 1. conda create -n pyimagej -c conda-forge pyimagej openjdk=8
# 2. conda activate pyimagej
#######################################################################################
import imagej
import numpy as np
# Open a tiff or h5 file in ImageJ by loading it to memory in several threads
######################################################################################
# Installation:
# 1. conda create -n pyimagej -c conda-forge pyimagej openjdk=8 scyjava dxchange h5py ipython
# 2. conda activate pyimagej
#######################################################################################
# Test:
# (pyimagej) usertxm@txmthree ~/vnikitin $ ipython -i parallel_read_to_imagej.py
import tomopy as tp
import numpy as np
import time
#timing functions
def tic():
global startTime_for_tictoc
startTime_for_tictoc = time.time()
def toc():
if 'startTime_for_tictoc' in globals():