-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented writer to save results and improved docs
- Loading branch information
Showing
4 changed files
with
107 additions
and
45 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from typing import Any, Dict, List | ||
|
||
import numpy as np | ||
|
||
|
||
def xyz_file_writer( | ||
path: str, layer_data: Any, attributes: Dict[str, Any] | ||
) -> List[str]: | ||
coordinates = np.array(layer_data) | ||
header = f"{len(coordinates)}\nProperties=Pos:R:3" | ||
|
||
if "particle_tracking_pixel_sizes" in attributes["metadata"]: | ||
# scale coordinates with pixel size | ||
coordinates *= np.array( | ||
attributes["metadata"]["particle_tracking_pixel_sizes"] | ||
) | ||
header += ' Unit="micrometer"' | ||
|
||
if "particle_tracking_settings" in attributes["metadata"]: | ||
# save particle tracking settings to txt file | ||
with open( | ||
path.replace(".xyz", "_params.txt"), "w", encoding="utf-8" | ||
) as f: | ||
for key, val in attributes["metadata"][ | ||
"particle_tracking_settings" | ||
].items(): | ||
f.write(f"{key} = {val}\n") | ||
|
||
np.savetxt(path, coordinates, comments="", header=header) # save .xyz file | ||
|
||
return [path] |
This file contains 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