Skip to content

Commit

Permalink
Merge pull request #232 from jhlegarreta/FixFloatingPointFormatting
Browse files Browse the repository at this point in the history
STYLE: Fix filename and dirname creation floating point formatting
  • Loading branch information
jhlegarreta authored Jun 28, 2024
2 parents 165cfcd + d7c6bd8 commit 39a5475
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions whitematteranalysis/congeal_multisubject.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ def iterate(self):

# make a directory for the current iteration
if self.mode == "Nonrigid":
dirname = f"iteration_{self.total_iterations:05d}_sigma_{self.sigma:03d}_grid_{self.nonrigid_grid_resolution:03d}"
dirname = f"iteration_{self.total_iterations:05d}_sigma_{int(self.sigma):03d}_grid_{int(self.nonrigid_grid_resolution):03d}"
else:
dirname = f"iteration_{self.total_iterations:05d}_sigma_{self.sigma:03d}"
dirname = f"iteration_{self.total_iterations:05d}_sigma_{int(self.sigma):03d}"

outdir = os.path.join(self.output_directory, dirname)
if not os.path.exists(outdir):
Expand Down Expand Up @@ -346,9 +346,9 @@ def iterate(self):
if have_mpl:
plt.figure(0)
if self.mode == "Nonrigid":
fname_fig_base = f"iteration_{self.total_iterations:05d}_sigma_{self.sigma:03d}_grid_{self.nonrigid_grid_resolution:03d}"
fname_fig_base = f"iteration_{self.total_iterations:05d}_sigma_{int(self.sigma):03d}_grid_{int(self.nonrigid_grid_resolution):03d}"
else:
fname_fig_base = f"iteration_{self.total_iterations:05d}_sigma_{self.sigma:03d}_"
fname_fig_base = f"iteration_{self.total_iterations:05d}_sigma_{int(self.sigma):03d}_"
# Place the legend below the plot so it does not overlap it when there are many subjects
#lgd = plt.legend(loc='upper center', bbox_to_anchor=(0.5, -0.15), fancybox=False, shadow=False, ncol=1)
fname_fig = f'objectives_per_subject_{fname_fig_base}.pdf'
Expand Down Expand Up @@ -405,9 +405,9 @@ def save_transformed_polydatas(self, intermediate_save=False, midsag_symmetric=F
# Make a directory for the current iteration.
# This directory name must match the one created above in the iteration.
if self.mode == "Nonrigid":
dirname = f"iteration_{self.total_iterations:05d}_sigma_{self.sigma:03d}_grid_{self.nonrigid_grid_resolution:03d}"
dirname = f"iteration_{self.total_iterations:05d}_sigma_{int(self.sigma):03d}_grid_{int(self.nonrigid_grid_resolution):03d}"
else:
dirname = f"iteration_{self.total_iterations:05d}_sigma_{self.sigma:03d}"
dirname = f"iteration_{self.total_iterations:05d}_sigma_{int(self.sigma):03d}"
outdir = os.path.join(self.output_directory, dirname)
if not os.path.exists(outdir):
os.makedirs(outdir)
Expand Down
4 changes: 2 additions & 2 deletions whitematteranalysis/congeal_to_atlas.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def iterate(self):
self.total_iterations += 1

# make a directory for the current iteration
dirname = f"iteration_{self.total_iterations:05d}_sigma_{ self.sigma:05d}"
dirname = f"iteration_{self.total_iterations:05d}_sigma_{int(self.sigma):05d}"
outdir = os.path.join(self.output_directory, dirname)
if not os.path.exists(outdir):
os.makedirs(outdir)
Expand Down Expand Up @@ -163,7 +163,7 @@ def save_transformed_polydata(self, intermediate_save=False):

if intermediate_save:
# make a directory for the current iteration
dirname = f"iteration_{self.total_iterations:05d}_sigma_{self.sigma:05d}"
dirname = f"iteration_{self.total_iterations:05d}_sigma_{int(self.sigma):05d}"
outdir = os.path.join(self.output_directory, dirname)
if not os.path.exists(outdir):
os.makedirs(outdir)
Expand Down

0 comments on commit 39a5475

Please sign in to comment.