This file contains hidden or 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
## Segmentation values and names are hardcoded (line 7). | |
## All segmentations should be in a single "segmentations" folder. | |
## This should match what is used in the config.yml for surface morphometrics | |
from sys import argv | |
import mrcfile | |
import os | |
import numpy as np | |
component_values = {"vesicle":1, | |
"er":2, |
This file contains hidden or 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
# Take two binary segmentations in mrc format and combine them, with the first segmentation having label 1 and the second segmentation having label 2. | |
import mrcfile | |
import numpy as np | |
import argparse | |
def combine_segmentations(seg1, seg2, clear_overlaps=True): | |
""" | |
Combine two binary segmentations into one, with the first segmentation having label 1 and the second segmentation having label 2. |
This file contains hidden or 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
## Convert all mitochondria STL files in current directory to SFF/HFF files | |
## Usage: python stl2sff.py FOLDERNAME | |
## Assumes there are multiple mitochondria per tomogram and up to one ER per tomogram. | |
## Performs both per-segment and global annotations based on assumption of MitoGFP MEF cells treated with thapsigargin (sometimes) | |
## Outputs HFF format sff files. | |
## Author: Benjamin Barad <[email protected]> with guidance from Paul Korir | |
import os | |
import sys | |
import glob |
This file contains hidden or 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
# Author: Benjamin Barad | |
# A quick script to erode the masks generated by warp to more tightly surround frost and beads | |
# Warp's neural net masking can be used to quickly remove gold beads and hunks of frost from tomograms. | |
# However, it tends to overmask and generate a nice big blob around each bead. This is desirable for | |
# limiting particle picking, but not for tomogram generation. This script erodes the mask to more tightly | |
# surround the frost and beads. | |
# Usage: | |
# 1. Run warp and generate masks for your tomograms with boxnet3mask | |
# 2. Close warp and rename the warp "mask" folder to "mask_raw" | |
# 3. Run this script as follows: |
This file contains hidden or 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# Adapted by Benjamin Barad ([email protected]) from code by Digvijay Singh ([email protected]) | |
# Run in an mdocs folder, makes an "Adjusted_mdoc" subfolder with corrected angles, which allows more flexibility for | |
# which program is used for tilt series alignment while guaranteeing a flat tomogram. I use it with etomo and warp primarily. | |
# Instead of identifying the "0" tilt based on transmission, you do it based on a predetermined milling angle. | |
# This has benefits and disadvantages, and is particularly useful if knowing absolute orientation is useful for future | |
# analysis. |
This file contains hidden or 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
# Adjust angles from imod alignment before warp import to allow flattening of tomograms | |
# Replaces imod's taSolution.log file with adjusted deltlts, while preserving the original file in taSolution.log.bak | |
# Author: Benjamin Barad 2022 | |
# Usage: | |
# cd WARPTOPFOLDER/imod | |
# python adjust_angles.py * | |
# Alternatively, instead of the wildcard individual tilt series folders can be specified. | |
import pandas as pd |
This file contains hidden or 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
from autoscript_sdb_microscope_client import SdbMicroscopeClient | |
import time | |
ip_address = '192.168.0.1' # depends on system setup | |
open_time = 1.5 # seconds | |
microscope = SdbMicroscopeClient() | |
microscope.connect(ip_address) | |
gis_port = microscope.gas.get_gis_port("Pt dep") | |
print(gis_port.get_temperature()) | |
gis_port.open() | |
time.sleep(open_time) |
This file contains hidden or 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
""" | |
Script to convert eman2 segmentation hdf maps to imod model files at a user defined contour level. | |
Requires python>=3.5 as well as having Eman2 and IMOD in the path. | |
Usage: `python3 tomoseg_to_imod.py -i EXAMPLE.hdf -o EXAMPLE.mod -t 0.8` | |
Author: Benjamin Barad <[email protected]> | |
""" | |
import argparse |
This file contains hidden or 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 imageio | |
import mrcfile | |
import os | |
import sys | |
def make_photos(basename, working_directory="."): | |
""" | |
Convert MRC file with stack of classes to series of scaled PNGs for web viewing. | |
Args: | |
basename (str): name of desired folder within class_images - usually the same name as the mrc file. |
This file contains hidden or 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 parse | |
import trace | |
filename_list = ["test_1.tpkl", "test_2.tpkl"] | |
for filename in filename_list: | |
trace = parse.parse(filename) | |
new_name = "{}.dat".format(filename[:-5]) | |
trace.write_dat(new_name) |
NewerOlder