def spider_ipfs(img, **extra): ''' ''' from arachnid.core.spider import spider from .. import ndimage_file import os #filter_type, filter_radius, pass_band, stop_band spi = spider.open_session(['file.spi'], spider_path=os.path.join(os.getcwd(), 'spider')) ndimage_file.write_image('test.spi', img) spi.ip_fs('test', outputfile='test_out', **extra) return ndimage_file.read_image('test_out.spi')
def spider_filter(img, **extra): ''' ''' from arachnid.core.spider import spider from .. import ndimage_file import os #filter_type, filter_radius, pass_band, stop_band spi = spider.open_session(['file.spi'], spider_path=os.path.join(os.getcwd(), 'spider')) ndimage_file.write_image('test.spi', img) spi.fq('test', outputfile='test_out', **extra) return ndimage_file.read_image('test_out.spi')
if __name__ == '__main__': # This line is not necessary for script execution, but helps when building the documentation input_volume = "input_volume.spi" # Filename for input file (should have extension) output_volume = "filtered_output_volume" # Filename for output file (extension optional) pixel_size = 1.2 # Pixel size of the volume resolution = 20 # Resolution to lowpass filter the volume # *** Uncomment the following to filter from 80 to 20 angstroms *** #resolution = (80, 20) # Create a SPIDER session using the extension of the input_volume # - Alternatively, you can specify the extension with data_ext="dat" for the .dat extension # - If no input file is given and no extension specified, the default is "spi" # - Note that, if you specify an extension then this overrides the extension of the input file spi = spider.open_session([input_volume], spider_path="", thread_count=0, enable_results=False, data_ext="") # Test whether to perform a band pass filter if not isinstance(resolution, tuple): # Filter the volume using the Gaussian lowpass filter to the specified `resolution` with the given `pixel_size` spi.fq(input_volume, spi.GAUS_LP, filter_radius=pixel_size/resolution, outputfile=output_volume) # Filter input_volume and write to output_volume else: # Filter the volume using the Butterworth highpass and Gaussian lowpass filter to the specified high and low `resolution` with the given `pixel_size` involume = spi.cp(input_volume) # Read volume to an incore file filtvolume = spi.fq(involume, spi.BUTER_LP, filter_radius=pixel_size/resolution[0]) # Highpass filter incore volume with Butterworth filtvolume = spi.fq(filtvolume, spi.GAUS_HP, filter_radius=pixel_size/resolution[1]) # Lowpass filter incore volume with Gaussian spi.cp(filtvolume, outputfile=output_volume) # Write incore filtered volume to a file # The above example can be shortened to two lines as follows if 1 == 0: # Do not run the following code - for illustrative purposes filtvolume = spi.fq(involume, spi.BUTER_LP, filter_radius=pixel_size/resolution[0]) # Highpass filter incore volume with Butterworth