Skip to content

Instantly share code, notes, and snippets.

View thorstenwagner's full-sized avatar

Thorsten Wagner thorstenwagner

View GitHub Profile
@thorstenwagner
thorstenwagner / map_array_alternative.py
Last active December 8, 2023 22:43
fast map array alternative
import numpy as np
from skimage.util import map_array
from time import perf_counter
from skimage.util import map_array
shape = (50,1024,1024)
total = shape[0]*shape[1]*shape[2]
NUM_LABELS=total*2
input_data = np.random.randint(NUM_LABELS,size=total).reshape(shape).astype("int64")
from_values = np.arange(NUM_LABELS)
@thorstenwagner
thorstenwagner / change.py
Last active February 23, 2021 08:12
isac_changes
--- a/sphire/sphire/bin/sp_gui.py
+++ b/sphire/sphire/bin/sp_gui.py
@@ -3093,7 +3093,10 @@ class SXCmdTab(QWidget):
self.qsub_script_edit = QLineEdit()
if self.sxcmdwidget.sxcmd.is_submittable == True:
- if 'SPHIRE_SUBMISSION_SCRIPT_TEMPLATE' in os.environ:
+ if 'SPHIRE_SUBMISSION_SCRIPT_TEMPLATE_GPU' in os.environ and \
+ self.sxcmdwidget.sxcmd.name in ('sp_isac2_gpu', ):
+ submission_script_template = os.environ['SPHIRE_SUBMISSION_SCRIPT_TEMPLATE_GPU']
def filter_single_image(img_path, filter_cutoff, resize_to_shape=None):
try:
image = imagereader.image_read(img_path)
except Exception:
print(img_path + " is corrupted. Ignore it.")
return None
return filter_single_image_np(image,filter_cutoff,resize_to_shape)
def filter_single_image_np(image, filter_cutoff, resize_to_shape=None):
Dear SPHIRE users!
we would like to inform you about the release of crYOLO 1.7.5! It fixes several bugs:
Fixed a problem where the training was not working if no filter (like Low pass or JANNI ) was used. (Thanks to Andrea Nans)
The config file value max_box_per_image is now adapted automatically to the given training data. If this value was lower than the number of labeled particles per micrograph, not all particle were taken into account during training. The automatic adaption ensures that it is high enough.
Fixed a crash of crYOLO when no particles were picked. (Thanks to Grigory Sharov)
@thorstenwagner
thorstenwagner / bla.py
Created November 14, 2019 15:15
blablub
#!/usr/bin/python
###This script is to convert the xml file after picking to .coords files (txt).
###It can take the rotation applied before picking.
###It will also split the coordinates based on boundary line drawn during picking.
import argparse
import numpy as np
import subprocess
import os
@thorstenwagner
thorstenwagner / example_cinderella.py
Created October 17, 2019 08:51
Example cinderella
from Auto2DSelect.auto_2d_select import Auto2DSelectNet # Import cinderella
from Auto2DSelect import results_writer # Import writer
batch_size =4 # If you have memory problems, choose a smaller one
input_path = "path/to/classes.hdf" # path to your classes
weights_path = "path/to/weights.h5" # path to your trained model
# You can read the input size from the trained model or just set it to size used during training.
with h5py.File(weights_path, mode="r") as f:
try:
@thorstenwagner
thorstenwagner / transform.py
Created September 25, 2019 11:13
transform coordinates
from scipy.spatial.transform import Rotation as R
import numpy as np
import star
import transphire_transform.dump_load.star as trs
import os
input_path = "data/run_it024_data.star"
results_path = "results/test_results/"
result_filename = "run_it024_data"
from __future__ import print_function
import argparse
import json
import os
from keras.utils import multi_gpu_model
import numpy as np
import time
from . import imagereader
from .frontend import YOLO
from .preprocessing import parse_annotation2
@thorstenwagner
thorstenwagner / PatchwiseBatchGenerator.py
Created October 3, 2018 14:41
PatchwiseBatchGenerator
from . import imagereader
from .augmentation import Augmentation
import cv2
import copy
from .utils import BoundBox, bbox_iou
import numpy as np
from keras.utils import Sequence
import threading
import multiprocessing
from multiprocessing import sharedctypes
public FloatProcessor generateMask(int mask_size, int filamentwidth, int maskwidth, int type){
FloatProcessor fp = new FloatProcessor(mask_size, mask_size);
double x0 = fp.getWidth()/2 + 0.5;
double y0 = fp.getHeight()/2 + 0.5;
double sigmax = maskwidth/2.355; //Full width at half maximum
double varx = sigmax*sigmax;
double sigmay = filamentwidth/2.355;
double vary = sigmay*sigmay;
for(int i = 0; i < mask_size; i++){