This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
def gen_interlaced_theta_W(): | |
numproj = 1440#1800-360 | |
prime = 2 | |
nProj_per_rot = 360 | |
pst = 0 | |
pend = 360 | |
seq = [] | |
i = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |