mrc_filename = realpath(args[0]) try: mrc = MRC(mrc_filename, readonly=True) except BaseException as e: help_msg(2, "Failed to open MRC file: " + str(e)) out_dir = realpath(args[1]) if not make_dir(out_dir): help_msg( 2, "Output directory already exists as regular file, choose another directory" ) # Check other arguments, getting values for optional args, etc. ext = "png" if ext == None else ext.lstrip('.') if basename == None: basename = "%04d" if x == None: x = (0, mrc.nx - 1) elif x[0] < 0 or x[1] < x[0] or x[1] >= mrc.nx: help_msg(2, "Invalid x argument supplied") if y == None: y = (0, mrc.ny - 1) elif y[0] < 0 or y[1] < y[0] or y[1] >= mrc.ny: help_msg(2, "Invalid x argument supplied") if z: min_z, max_z = min(z), max(z) if min_z < 0 or max_z >= mrc.nz: help_msg(2, "Invalid z argument supplied") imf = imfilter_util.list2imfilter(imfilters) # Do the actual work! mrc2stack(mrc.view(x, y, (0, mrc.nz - 1)), out_dir, z, basename + "." + ext, imf)
x = (int(x[0]), int(x[1])) elif o == "-y": if y != None: help_msg(2, "May be only one y argument") y = y.split("-") if len(y) != 2 or not y[0].isdigit() or not y[1].isdigit(): help_msg(2, "Invalid y argument supplied") y = (int(y[0]), int(y[1])) else: imfilters += [imfilter_util.parse_opt(o,a,help_msg)] # Make sure paths are good if len(args) != 2: help_msg(2, "You need to provide an MRC and image output directory as arguments") mrc_filename = realpath(args[0]) try: mrc = MRC(mrc_filename, readonly=True) except BaseException as e: help_msg(2, "Failed to open MRC file: " + str(e)) out_dir = realpath(args[1]) if not make_dir(out_dir): help_msg(2, "Output directory already exists as regular file, choose another directory") # Check other arguments, getting values for optional args, etc. ext = "png" if ext == None else ext.lstrip('.') if basename == None: basename = "%04d" if x == None: x = (0, mrc.nx - 1) elif x[0] < 0 or x[1] < x[0] or x[1] >= mrc.nx: help_msg(2, "Invalid x argument supplied") if y == None: y = (0, mrc.ny - 1) elif y[0] < 0 or y[1] < y[0] or y[1] >= mrc.ny: help_msg(2, "Invalid x argument supplied") if z: min_z, max_z = min(z), max(z) if min_z < 0 or max_z >= mrc.nz: help_msg(2, "Invalid z argument supplied") imf = imfilter_util.list2imfilter(imfilters) # Do the actual work! mrc2stack(mrc.view(x, y, (0, mrc.nz - 1)), out_dir, z, basename+"."+ext, imf)