You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ cryodrgn_utils flip_hand vol_000.mrc -o tmp.mrc
Traceback (most recent call last):
File "/Users/zhonge/anaconda3/envs/cryodrgn/bin/cryodrgn_utils", line 8, in <module>
sys.exit(util_commands())
File "/Users/zhonge/dev/cryodrgn/cryodrgn/command_line.py", line 53, in util_commands
_get_commands(os.path.join(os.path.dirname(__file__), "commands_utils"))
File "/Users/zhonge/dev/cryodrgn/cryodrgn/command_line.py", line 43, in _get_commands
args.func(args)
File "/Users/zhonge/dev/cryodrgn/cryodrgn/commands_utils/flip_hand.py", line 24, in main
MRCFile.write(
File "/Users/zhonge/dev/cryodrgn/cryodrgn/mrc.py", line 260, in write
header = MRCHeader.make_default_header(
File "/Users/zhonge/dev/cryodrgn/cryodrgn/mrc.py", line 142, in make_default_header
dmin, dmax, dmean, rms = data.min(), data.max(), data.mean(), data.std()
AttributeError: 'MRCFileSource' object has no attribute 'min'
$ cryodrgn_utils invert_contrast vol_000.mrc -o tmp.mrc
Traceback (most recent call last):
File "/Users/zhonge/anaconda3/envs/cryodrgn/bin/cryodrgn_utils", line 8, in <module>
sys.exit(util_commands())
File "/Users/zhonge/dev/cryodrgn/cryodrgn/command_line.py", line 53, in util_commands
_get_commands(os.path.join(os.path.dirname(__file__), "commands_utils"))
File "/Users/zhonge/dev/cryodrgn/cryodrgn/command_line.py", line 43, in _get_commands
args.func(args)
File "/Users/zhonge/dev/cryodrgn/cryodrgn/commands_utils/invert_contrast.py", line 22, in main
MRCFile.write(args.o, src, transform_fn=lambda data, indices: -data)
File "/Users/zhonge/dev/cryodrgn/cryodrgn/mrc.py", line 260, in write
header = MRCHeader.make_default_header(
File "/Users/zhonge/dev/cryodrgn/cryodrgn/mrc.py", line 142, in make_default_header
dmin, dmax, dmean, rms = data.min(), data.max(), data.mean(), data.std()
AttributeError: 'MRCFileSource' object has no attribute 'min'
The text was updated successfully, but these errors were encountered:
I was able to reproduce these errors with an MRCFile volume generated by abinit_homo, and both commands worked fine with the ImageSource volumes currently used for testing. This suggests we need to do some deeper cleaning of the MRCFile and ImageSource classes and the code where they are used, but for now I have fixed the behavior in mrc.make_default_header that was causing this behaviour:
if is_vol:
if data is None:
raise ValueError("If is_vol=True, data array must be specified")
if isinstance(data, (np.ndarray, torch.Tensor)):
dmin, dmax, dmean, rms = data.min(), data.max(), data.mean(), data.std()
elif isinstance(data, ImageSource):
imgdata = data.images()
dmin = imgdata.min().item()
dmax = imgdata.max().item()
dmean = imgdata.mean().item()
rms = imgdata.std().item()
else:
raise TypeError(f"Unrecognized type of data: `{type(data).__name__}`!")
else: # use undefined values for image stacks
dmin, dmax, dmean, rms = -1, -2, -3, -1
I've also added more cases to test_flip_hand and test_invert_contrast that specifically cover this example!
The text was updated successfully, but these errors were encountered: