-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Header issues #31
Header issues #31
Conversation
@@ -84,7 +84,7 @@ def extract_patches( | |||
pad_value = 2.0 # Currently still hard-coded because other values not | |||
# compatible with training routine yet. | |||
if coords_file is not None: | |||
coords = get_csv_data(csv_path=coords_file) | |||
coords = np.array(get_csv_data(csv_path=coords_file), dtype=int) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was read as strings sometimes, and thus did not extract patches properly.
if found_flag == 0: | ||
print("No corrections folder found for patch", token) | ||
if found_flag == 0: | ||
print("No corrections folder found for patch", token) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This warning message was on the wrong level of the loop and thus given too often.
@@ -118,7 +118,7 @@ def load_data_for_inference(data_path: str, transforms: Callable, device: device | |||
new_data = transforms(new_data) | |||
new_data = new_data.unsqueeze(0) # Add batch dimension | |||
new_data = new_data.to(device) | |||
return new_data, tomogram.header | |||
return new_data, tomogram.header, tomogram.voxel_size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read additionally the tomogram's voxel size in order to store it properly later on.
@@ -334,7 +342,7 @@ def convert_dtype(tomogram: np.ndarray) -> np.ndarray: | |||
if ( | |||
tomogram.min() >= np.finfo("float16").min | |||
and tomogram.max() <= np.finfo("float16").max | |||
): | |||
) and np.allclose(tomogram, tomogram.astype("float16")): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was causing rounding to integers sometimes.
"my", | ||
"mz", | ||
]: | ||
if attr not in ["nlabl", "label"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only copy these harmless header objects.
Not sure what exactly is valuable from the header, but since some stuff causes problems, better to be conservative I guess.
|
||
data = convert_dtype(data) | ||
data = np.transpose(data, (2, 1, 0)) | ||
out_mrc.set_data(data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting the data is generating some header elements. Since these are data dependent, it's better to not have them overwritten with the above header loop.
Thus, I changed the order of data setting and header definition.
Trying to fix some header issues arising from copying the header from the input tomogram.
Particularly, I'm only copying the labels from the original header, and the voxel size. Also, I changed the order of header declaration and setting the data, s.t. the automated header settings from setting the data will not be overwritten.
Also changed a small bug in reading the .csv file for extracting annotation patches.