Skip to content

Commit

Permalink
Merge pull request #72 from elgw/dev
Browse files Browse the repository at this point in the history
Fix for issue #70
  • Loading branch information
elgw committed Jun 22, 2024
2 parents 4544dc1 + 984c5a4 commit 325d90d
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 17 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# CHANGELOG

## 0.4.3
- Fixed [issue #70](https://github.com/elgw/deconwolf/issues/70) which
affected windows builds only.

- Dw will now give a error message if the log file can't be opened
instead of quietly crashing.

- Disabled some debug code that caused dw to write the file
(`one.tif`) every time that is was run. It has been doing so since
version 0.4.1.

## 0.4.2
- VkFFT upgraded from v1.3.3 to v1.3.4.
- Fixed an issue preventing anything than `--bq 0` to be used on
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# deconwolf v0.4.2
# deconwolf v0.4.3

**deconwolf**[^9] is a software for 3-D deconvolution of fluorescent wide-field
images:
Expand Down
29 changes: 20 additions & 9 deletions src/dw.c
Original file line number Diff line number Diff line change
Expand Up @@ -934,19 +934,20 @@ void dw_argparsing(int argc, char ** argv, dw_opts * s)
}


/* Set s->outFile and s->outFolder based on s->imFile */
if(s->outFile == NULL)
{
/* Set s->outFile and s->outFolder based on s->imFile */
char * dname = dw_dirname(s->imFile);
char * bname = dw_basename(s->imFile);
s->outFile = malloc(strlen(dname) + strlen(bname) + strlen(s->prefix) + 10);
assert(s->outFile != NULL);
sprintf(s->outFile, "%s%c%s_%s", dname, FILESEP, s->prefix, bname);
{
s->outFile = dw_prefix_file(s->imFile, s->prefix);

char * dname = dw_dirname(s->imFile);
s->outFolder = malloc(strlen(dname) + 16);
assert(s->outFolder != NULL);
sprintf(s->outFolder, "%s%c", dname, FILESEP);
free(bname);
sprintf(s->outFolder, "%s%c", dname, FILESEP);
free(dname);
if(s->verbosity > 1)
{
printf("outFile: %s, outFolder: %s\n", s->outFile, s->outFolder);
}
} else {
char * dname = dw_dirname(s->outFile);
free(s->outFolder);
Expand Down Expand Up @@ -1980,6 +1981,14 @@ float * psf_makeOdd(float * psf, int64_t * pM, int64_t * pN, int64_t *pP)
void dcw_init_log(dw_opts * s)
{
s->log = fopen(s->logFile, "w");
if (s->log == NULL)
{
fprintf(stderr, "Unable to open %s for writing\n", s->logFile);
fprintf(stderr,
"Please check that you have permissions to write to the folder\n"
"and that the drive is not full\n");
exit(EXIT_FAILURE);
}
assert(s->log != NULL);
show_time(s->log);
dw_opts_fprint(s->log, s);
Expand Down Expand Up @@ -2072,6 +2081,8 @@ fftwf_complex * initial_guess(const int64_t M, const int64_t N, const int64_t P,
}
}
}
//printf("writing to one.tif");
//fim_tiff_write_float("one.tif", one, NULL, wM, wN, wP);
// writetif("one.tif", one, wM, wN, wP);

fftwf_complex * Fone = fft(one, wM, wN, wP);
Expand Down
48 changes: 42 additions & 6 deletions src/dw_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,24 +85,26 @@ void dw_gettime(struct timespec * t)

char * dw_dirname(const char * path)
{
#ifdef WINDOWS
#ifdef WINDOWS
size_t maxlen = strlen(path)+1;
char * drive = malloc(maxlen);
char * dir = malloc(maxlen);

_splitpath(path, drive, dir, NULL, NULL);
char * outpath = malloc(maxlen);
_makepath(outpath, drive, dir, NULL, NULL);
// Adds a trailing '\'
free(drive);
free(dir);
return outpath;
#else
#else
char * t = strdup(path);
char * _dir = dirname(t); // should not be freed
// Does not add a trailing '/'
char * dir = strdup(_dir);
free(t);
return dir;
#endif
#endif
}

char * dw_basename(const char * path)
Expand All @@ -128,11 +130,11 @@ char * dw_basename(const char * path)

char * dw_getcwd(char * buf, size_t size)
{
#ifdef WINDOWS
#ifdef WINDOWS
return _getcwd(buf, size);
#else
#else
return getcwd(buf, size);
#endif
#endif
}

int ptr_alignment_B(const void * p)
Expand Down Expand Up @@ -354,7 +356,40 @@ int getline(char **lineptr, size_t *n, FILE *stream)
char *
dw_prefix_file(const char * inFile, const char * prefix)
{
#ifdef WINDOWS

char* drive = calloc(strlen(inFile) + 16, 1);
char* dir = calloc(strlen(inFile) + 16, 1);
char* fname = calloc(strlen(inFile) + 16, 1);
char* ext = calloc(strlen(inFile) + 16, 1);

_splitpath(
inFile,
drive,
dir,
fname,
ext
);

char* pre_fname = calloc(strlen(fname) + strlen(prefix) + 16, 1);
sprintf(pre_fname, "%s_%s", prefix, fname);
char* outFile = calloc(strlen(inFile) + strlen(prefix) + 128, 1);

_makepath(
outFile,
drive,
dir,
pre_fname,
ext
);

free(drive);
free(dir);
free(fname);
free(pre_fname);
free(ext);
return outFile;
#else
char * dname = dw_dirname(inFile);
assert(dname != NULL);
char * fname = dw_basename(inFile);
Expand All @@ -373,6 +408,7 @@ dw_prefix_file(const char * inFile, const char * prefix)
free(fname);

return outFile;
#endif
}

float abbe_res_xy(float lambda, float NA)
Expand Down
2 changes: 1 addition & 1 deletion src/dw_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#define DW_VERSION_MAJOR "0"
#define DW_VERSION_MINOR "4"
#define DW_VERSION_PATCH "2"
#define DW_VERSION_PATCH "3"
#define deconwolf_version DW_VERSION_MAJOR "." \
DW_VERSION_MINOR "." \
DW_VERSION_PATCH

0 comments on commit 325d90d

Please sign in to comment.