Skip to content

Instantly share code, notes, and snippets.

@alisterburt
alisterburt / for_jacob.py
Created July 14, 2022 13:42
generate relion matrices from IMOD metadata
import numpy as np
import einops
import starfile
from yet_another_imod_wrapper.utils.io import read_xf, read_tlt
XF_FILE = 'imod_TS_01/TS_01.xf'
TLT_FILE = 'imod_TS_01/TS_01.tlt'
TILT_IMAGE_DIMENSIONS = (3710, 3838) # (x, y)
@alisterburt
alisterburt / imod_model_to_rln3_star_file.py
Created May 18, 2022 05:08
convert a set of IMOD models to a RELION 3 star file for warp (for matteo)
from pathlib import Path
from typing import Tuple
import eulerangles
import imodmodel
import numpy as np
import pandas as pd
import starfile as starfile
from pydantic import BaseModel
@biochem-fan
biochem-fan / NOTES.md
Last active August 7, 2025 12:30
Warp-RELION4-M Protocol
@Edenhofer
Edenhofer / interpolate.py
Last active August 19, 2023 13:13
Implementation of SciPy's RegularGridInterpolator in JAX
#!/usr/bin/env python3
from jax import numpy as jnp
import numpy as np
from scipy.interpolate import RegularGridInterpolator as _si_RegularGridInterpolator
class RegularGridInterpolator:
# Based on SciPy's implementation which in turn is originally based on an
# implementation by Johannes Buchner
@hanjinliu
hanjinliu / classgui.py
Created September 5, 2021 14:34
Convert a class into a QWidget and the methods into push buttons.
from __future__ import annotations
import inspect
from magicgui import magicgui
import napari
from qtpy.QtWidgets import QPushButton, QWidget, QVBoxLayout
# Usage:
# >>> viewer = napari.Viewer()
# >>> cgui = ClassGui(viewer)
# >>> @cgui.from_class
@YoraiLevi
YoraiLevi / KnownFolderPathPS5.ps1
Last active November 21, 2025 15:48
Change windows user folders with powershell
<#
.SYNOPSIS
Requires powershell 5 or later
Provides Get and Set functions for KnownFolders
.EXAMPLE
PS> Set-KnownFolderPath Desktop $ENV:USERPROFILE/Desktop
.EXAMPLE
PS> $Path=""
PS> Get-KnownFolderPath Desktop ([ref]$Path)
.LINK
@alisterburt
alisterburt / vll2table.m
Created October 7, 2020 14:01
dynamo vll file to table and table map
function table = vll2table(vll_file)
%%% Convert a vll file into a table and corresponding tomogram table-map file
% Read volume list file
volume_list = ptdb.volumelisttext2object(vll_file).volumes;
% Prepare output filenames
table_file_name = strrep(vll_file, '.vll', '.tbl');
table_map_file_name = strrep(vll_file, '.vll', '_tablemap.doc');
@alisterburt
alisterburt / dms2mod.m
Created October 6, 2020 07:52
convert dynamo markers files into imod model files
function dms2mod(markers_dms_file, model_file, image_file)
%%%%% Convert Dynamo markers (.dms files) into IMOD format model files (.mod)
%%%%% Requires MATLAB >= r2019a
%%%%% Requires Dynamo >= 1.1.478
%%%%% Requires IMOD >= 4.10.37
%%% Reading marker file
m = dread(markers_dms_file);
%%% Extract useful objects
markers = m.shapes;
/* BoxNet2D runner
* Based on Warp 1.0.7 by Dimitry Tegunov https://github.com/cramerlab/warp/
* Command line interface and Linux port by @biochem_fan
* Licensed under GPLv3
*/
using System;
using System.IO;
using System.Linq; // for toList()
using System.Diagnostics; // for Stopwatch
#!/bin/bash
if [[ ! -d 3DEM ]]
then
mkdir 3DEM
fi
cd 3DEM
curl -s http://mail.ncmir.ucsd.edu/pipermail/3dem/ |\