diff --git a/.gitignore b/.gitignore
index d1d270a..bf6c02a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,13 +5,11 @@ testData
test_data/psf.dv
test_data/GPUsirecon/*
test_data/proc.dv
-IVE
lapack
*dist
fftw2
cmake_build
-src/IVE
_test.sh
src/cudaSirecon/cudasireconConfig.h
src/cudasireconConfig.h
diff --git a/README.md b/README.md
index e00e338..5451472 100644
--- a/README.md
+++ b/README.md
@@ -258,40 +258,3 @@ conda env create -f environment-windows.yml
conda activate simbuild
bld.bat # see bld.bat for cmake details
```
-
-### Building with MRC support
-
-The IVE/Priism libraries (for MRC/DV support), are not distributed with this
-source code and must be acquired seperately from UCSF. Place them in a folder
-called `IVE` at the top level of the source folder (same folder as the
-cudaSirecon folder). It should minimally have the following files and folders
-(example shown for linux, use `.a` or `.lib` as necessary for osx or windows)
-
-then build with `cmake -DBUILD_MRC=ON ....`
-
-
-
-required IVE folder structure
-
-```
-cudasirecon
-├── ...
-└── IVE/
- ├── darwin64/
- │ ├── INCLUDE/
- │ └── LIB/
- ├── linux64/
- │ ├── INCLUDE/
- │ │ ├── IM.h
- │ │ ├── IMInclude.h
- │ │ └── IWApiConstants.h
- │ └── LIB/
- │ ├── libimlib.a
- │ └── libive.a
- └── win64/
- ├── INCLUDE/
- └── LIB/
-```
-
-
-
diff --git a/VStutio_project/VStutio_project.vcxproj b/VStutio_project/VStutio_project.vcxproj
index 5c9b677..7a29bae 100644
--- a/VStutio_project/VStutio_project.vcxproj
+++ b/VStutio_project/VStutio_project.vcxproj
@@ -144,7 +144,7 @@
true
true
WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
- $(CUDA_PATH)/include;../Buffers;C:/libtiff;../IVE/win64/INCLUDE;C:/Boost/boost_1_55_0
+ $(CUDA_PATH)/include;../Buffers;C:/libtiff;C:/Boost/boost_1_55_0
None
@@ -152,8 +152,8 @@
true
true
true
- C:\Boost\boost_1_55_0\lib;$(CUDA_PATH)\lib\x64;C:\libtiff;..\lapack\win64;..\IVE\win64\lib;$(SolutionDir)
- cuda.lib;cudart.lib;cufft.lib;libtiff.lib;liblapack.lib;libblas.lib;libimlib.lib;libive.lib;Buffers.lib;%(AdditionalDependencies)
+ C:\Boost\boost_1_55_0\lib;$(CUDA_PATH)\lib\x64;C:\libtiff;..\lapack\win64;$(SolutionDir)
+ cuda.lib;cudart.lib;cufft.lib;libtiff.lib;liblapack.lib;libblas.lib;Buffers.lib;%(AdditionalDependencies)
64
diff --git a/bld.bat b/bld.bat
index eab9062..702e216 100644
--- a/bld.bat
+++ b/bld.bat
@@ -1,19 +1,15 @@
-del /Q cmake_build
+@REM rmdir /S /Q cmake_build
-@REM if not exist src\IVE\ (
-@REM powershell -Command "Invoke-WebRequest https://www.dropbox.com/s/2twvw0go3dr3aim/IVE.zip -OutFile IVE.zip"
-@REM powershell -Command "Expand-Archive IVE.zip -DestinationPath src\"
-@REM del IVE.zip )
+call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
-mkdir cmake_build
+@REM mkdir cmake_build
cd cmake_build
-cmake -G Ninja ^
- -DBUILD_MRC=ON ^
- -DBUILD_OTF_VIEWER=OFF ^
- -DCMAKE_BUILD_TYPE=Release ^
- -DCMAKE_INSTALL_PREFIX="%CONDA_PREFIX%/Library" ^
- ../src
+@REM cmake -G Ninja ^
+@REM -DBUILD_OTF_VIEWER=OFF ^
+@REM -DCMAKE_BUILD_TYPE=Release ^
+@REM -DCMAKE_INSTALL_PREFIX="%CONDA_PREFIX%/Library" ^
+@REM ../src
ninja
-ninja install
+@REM ninja install
diff --git a/build.sh b/build.sh
index 9be1703..7ab0d64 100755
--- a/build.sh
+++ b/build.sh
@@ -1,23 +1,14 @@
rm -rf cmake_build
-if [ ! -d "src/IVE" ]
-then
- wget src/ https://www.dropbox.com/s/2twvw0go3dr3aim/IVE.zip
- unzip -o -d src IVE.zip
- rm IVE.zip
-fi
-
-
mkdir cmake_build
cd cmake_build
CXXFLAGS="$CXXFLAGS -Wfatal-errors -Wno-deprecated-declarations"
cmake ${CMAKE_ARGS} \
- -DBUILD_MRC=ON \
-DBUILD_OTF_VIEWER=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \
../src
-make -j 2
-make install
+make -j 4
+# make install
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index db5a883..d90598c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -9,14 +9,6 @@
# includes the nvcc compiler For windows, you will need to install the CUDA
# toolkit manually
#
-# 1. MRC/DV support (optional) If you want to build with MRC support add the IVE
-# libraries to the src directory with the following paths: For Linux:
-# src/IVE/linux64/INCLUDE src/IVE/linux64/LIB For Windows:
-# src/IVE/win64/INCLUDE src/IVE/win64/LIB
-#
-# If you DON'T want to build with MRC or do not have access to the IVE libraries
-# please run cmake with the `-DBUILD_MRC=OFF` option
-#
# To build the otfviewer, use `-DBUILD_OTF_VIEWER=ON`
#
# 1. run build.sh (linux) or bld.bat (windows) inspect those scripts for more
@@ -81,33 +73,6 @@ endif(WIN32)
message(STATUS "CUDA_NVCC_FLAGS: " ${CUDA_NVCC_FLAGS})
-if(BUILD_MRC OR BUILD_OTF_VIEWER)
- message(STATUS "** Building WITH mrc support **")
-
- if(WIN32)
- set(PLATFORM win64)
- else()
- set(PLATFORM linux64)
- endif(WIN32)
-
- set(PRIISM_LIB_PATH "${CMAKE_SOURCE_DIR}/IVE/${PLATFORM}/LIB")
- set(PRIISM_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/IVE/${PLATFORM}/INCLUDE")
- include_directories(${PRIISM_INCLUDE_PATH})
- link_directories(${PRIISM_LIB_PATH})
-
- find_library(
- IMLIB
- NAMES imlib libimlib
- PATHS ${PRIISM_LIB_PATH} REQUIRED)
- find_library(
- IVELIB
- NAMES ive libive
- PATHS ${PRIISM_LIB_PATH} REQUIRED)
- add_definitions(-DMRC)
-else()
- message(STATUS "** Building WITHOUT mrc support **")
-endif()
-
add_subdirectory(Buffers)
add_subdirectory(cudaSirecon)
add_subdirectory(otf)
diff --git a/src/cudaSirecon/CMakeLists.txt b/src/cudaSirecon/CMakeLists.txt
index 0ce959a..09164c4 100644
--- a/src/cudaSirecon/CMakeLists.txt
+++ b/src/cudaSirecon/CMakeLists.txt
@@ -3,8 +3,6 @@ include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}/../Buffers")
find_package(LAPACK REQUIRED)
-message(STATUS "IMLIB: " ${IMLIB})
-message(STATUS "IVELIB: " ${IVELIB})
message(STATUS "LEG_STDIO: " ${LEG_STDIO})
message(STATUS "LAPACK_FOUND: " ${LAPACK_FOUND})
@@ -23,8 +21,7 @@ target_link_libraries(
${BOOST_LIBRARIES}
${Boost_PROGRAM_OPTIONS_LIBRARY}
${Boost_FILESYSTEM_LIBRARY}
- ${IMLIB}
- ${IVELIB})
+)
# cudasirecon executable file
diff --git a/src/cudaSirecon/SIM_reconstructor.hpp b/src/cudaSirecon/SIM_reconstructor.hpp
index 973c057..9f3de70 100644
--- a/src/cudaSirecon/SIM_reconstructor.hpp
+++ b/src/cudaSirecon/SIM_reconstructor.hpp
@@ -105,9 +105,7 @@ class SIM_Reconstructor {
int m_zoffset;
po::options_description m_progopts;
po::variables_map m_varsmap;
- #ifdef MRC
IW_MRC_HEADER m_in_out_header;
- #endif
bool m_OTFfile_valid;
int m_argc;
diff --git a/src/cudaSirecon/cudaSirecon.cpp b/src/cudaSirecon/cudaSirecon.cpp
index b47e905..c96de5b 100644
--- a/src/cudaSirecon/cudaSirecon.cpp
+++ b/src/cudaSirecon/cudaSirecon.cpp
@@ -1,13 +1,10 @@
-#include "cudaSirecon.h"
#include "cudaSireconImpl.h"
+#include "mrc.h"
#include "SIM_reconstructor.hpp"
#include "cudasireconConfig.h"
#include
-#ifdef MRC
-#include "mrc.h"
-#endif
std::string version_number = std::to_string(cudasirecon_VERSION_MAJOR) + "." +
std::to_string(cudasirecon_VERSION_MINOR) + "." +
@@ -167,7 +164,6 @@ void getbg_and_slope(const char *corrfiles, float *background,
int ixyz[3], mxyz[3], pixeltype; /* variables for IMRdHdr call */
float min, max, mean; /* variables for IMRdHdr call */
-#ifdef MRC
IW_MRC_HEADER header;
if (IMOpen(cstream_no, corrfiles, "ro")) {
fprintf(stderr, "File %s does not exist\n", corrfiles);
@@ -188,7 +184,6 @@ void getbg_and_slope(const char *corrfiles, float *background,
IMRdSec(cstream_no, slope);
IMClose(cstream_no);
-#endif
}
void findModulationVectorsAndPhasesForAllDirections(
@@ -271,7 +266,6 @@ void findModulationVectorsAndPhasesForAllDirections(
// TO-DO
std::cout << "No unmixed raw images were saved in TIFF mode\n";
}
- #ifdef MRC
else if (!params->bTIFF && params->bSaveSeparated) {
CPUBuffer tmp((*rawImages)[0].getSize());
for (int phase = 0; phase < params->nphases; ++ phase) {
@@ -284,7 +278,6 @@ void findModulationVectorsAndPhasesForAllDirections(
}
continue; // skip the k0 search and modamp fitting
}
- #endif
/* After separation and FFT, the std::vector rawImages, now referred to as
@@ -337,7 +330,6 @@ void findModulationVectorsAndPhasesForAllDirections(
true); // ovlp0 shares buffer with tmp0 (hence "true" in the final parameter)
ovlp0.save_tiff(params->fileOverlaps.c_str());
}
- #ifdef MRC
else {
CPUBuffer tmp0(data->overlap0.getSize());
data->overlap0.set(&tmp0, 0, tmp0.getSize(), 0);
@@ -350,7 +342,6 @@ void findModulationVectorsAndPhasesForAllDirections(
IMWrSec(overlaps_stream_no, ol1Ptr + z * imgParams.nx * imgParams.ny);
}
}
- #endif
}
printf("Initial guess by findk0() of k0[direction %d] = (%f,%f) pixels\n",
direction, data->k0[direction].x/dkx, data->k0[direction].y/dky);
@@ -429,7 +420,6 @@ void findModulationVectorsAndPhasesForAllDirections(
// To-DO
std::cout << "No overlaps were saved in TIFF mode";
}
- #ifdef MRC
else if (!params->bTIFF && order == 1 && params->bSaveOverlaps) {// output the overlaps
// output the overlaps
CPUBuffer tmp0(data->overlap0.getSize());
@@ -443,7 +433,6 @@ void findModulationVectorsAndPhasesForAllDirections(
IMWrSec(overlaps_stream_no, ol1Ptr + z * imgParams.nx * imgParams.ny);
}
}
- #endif
}
} /* if(searchforvector) ... else ... */
@@ -856,10 +845,6 @@ SIM_Reconstructor::SIM_Reconstructor(int argc, char **argv)
// Suppress "unknown field" warnings
TIFFSetWarningHandler(NULL);
m_imgParams.ntimes = m_all_matching_files.size();
- } else {
- #ifndef MRC
- throw std::runtime_error("No tiff files found, and program was not compiled with MRC support.");
- #endif
}
m_OTFfile_valid = false;
@@ -867,10 +852,8 @@ SIM_Reconstructor::SIM_Reconstructor(int argc, char **argv)
// deviceMemoryUsage();
setup();
- #ifdef MRC
if (!m_myParams.bTIFF)
::setOutputHeader(m_myParams, m_imgParams, m_in_out_header);
- #endif
//! Load flat-field correction data
bgAndSlope(m_myParams, m_imgParams, &m_reconData);
}
@@ -1074,7 +1057,6 @@ void SIM_Reconstructor::openFiles() {
throw std::runtime_error(
"Calling openFiles() but no input or output files were specified");
-#ifdef MRC
if (!m_myParams.bTIFF && IMOpen(istream_no, m_myParams.ifiles.c_str(), "ro"))
// TIFF files are not opened till loadAndRescaleImage()
throw std::runtime_error("No matching input TIFF or MRC files not found");
@@ -1086,19 +1068,16 @@ void SIM_Reconstructor::openFiles() {
std::cerr << "File " << m_myParams.ofiles << " can not be created.\n";
throw std::runtime_error("Error creating output file");
}
-#endif
if (m_myParams.bTIFF) {
// will throw CImgIOException if file cannot be opened
m_otf_tiff.assign(m_myParams.otffiles.c_str());
m_OTFfile_valid = true;
}
-#ifdef MRC
else if (IMOpen(otfstream_no, m_myParams.otffiles.c_str(), "ro"))
throw std::runtime_error("OTF file not found");
else
m_OTFfile_valid = true;
-#endif
}
void SIM_Reconstructor::setup(unsigned nx, unsigned ny, unsigned nImages, unsigned nChannels)
@@ -1126,10 +1105,8 @@ void SIM_Reconstructor::setup()
m_imgParams.nwaves = tiff0.spectrum(); // multi-color not supported yet
m_imgParams.nz /= m_imgParams.nwaves * m_myParams.nphases * m_myParams.ndirs;
}
-#ifdef MRC
else
::loadHeader(m_myParams, &m_imgParams, m_in_out_header);
-#endif
printf("nx_raw=%d, ny=%d, nz=%d\n",
m_imgParams.nx_raw, m_imgParams.ny, m_imgParams.nz);
@@ -1176,8 +1153,7 @@ void SIM_Reconstructor::setup_common()
m_imgParams.nz0, m_imgParams.nwaves);
printf("dxy=%f, dz=%f um\n", m_imgParams.dxy, m_imgParams.dz);
- #ifdef MRC
- // // Initialize headers for intermediate output files if requested
+ // Initialize headers for intermediate output files if requested
if (!m_myParams.bTIFF) {
if (m_myParams.bSaveAlignedRaw) {
memcpy(&aligned_header, &m_in_out_header, sizeof(m_in_out_header));
@@ -1207,7 +1183,6 @@ void SIM_Reconstructor::setup_common()
IMPutHdr(overlaps_stream_no, &overlaps_header);
}
}
- #endif
m_myParams.norders = 0;
if (m_myParams.norders_output != 0) {
@@ -1283,10 +1258,8 @@ int SIM_Reconstructor::processOneVolume()
// deviceMemoryUsage();
- #ifdef MRC
if (saveIntermediateDataForDebugging(m_myParams))
return 0;
- #endif
m_reconData.bigbuffer.resize((m_myParams.zoomfact * m_imgParams.nx) *
(m_myParams.zoomfact * m_imgParams.ny) * (m_myParams.z_zoom * m_imgParams.nz0) *
@@ -1339,7 +1312,6 @@ void SIM_Reconstructor::setFile(int it, int iw)
if (m_myParams.bTIFF) {
rawImage.assign(m_all_matching_files[it].c_str());
}
- #ifdef MRC
else {
rawImage.assign(m_imgParams.nx_raw, m_imgParams.ny, m_imgParams.nz * m_myParams.nphases * m_myParams.ndirs);
for (unsigned sec=0; sec
using namespace cimg_library;
-#ifdef MRC
-#include // MRC file I/O routines
-#endif
-
+#include "dvfile.h"
// Block sizes for reduction kernels
#define RED_BLOCK_SIZE_X 64
@@ -74,12 +71,10 @@ static const int aligned_stream_no = 10;
static const int separated_stream_no = 11;
static const int overlaps_stream_no = 12;
-#ifdef MRC
// static IW_MRC_HEADER header;
static IW_MRC_HEADER aligned_header;
static IW_MRC_HEADER sep_header;
static IW_MRC_HEADER overlaps_header;
-#endif
struct myExtHeader {
float timestamp;
@@ -249,18 +244,14 @@ void SetDefaultParams(ReconParams *pParams);
* */
// void setup(ReconParams* params, ImageParams*
// imgParams, DriftParams* driftParams, ReconData* data);
-#ifdef MRC
void loadHeader(const ReconParams& params, ImageParams* imgParams, IW_MRC_HEADER &header);
-#endif
void allocateOTFs(ReconParams *pParams, int sizeOTF, std::vector > & otfs);
void allocateImageBuffers(const ReconParams& params,
const ImageParams& imgParams, ReconData* reconData);
-#ifdef MRC
void setOutputHeader(const ReconParams& myParams, const ImageParams& imgParams,
IW_MRC_HEADER &header);
-#endif
void bgAndSlope(const ReconParams& myParams,
const ImageParams& imgParams, ReconData* reconData);
@@ -289,9 +280,7 @@ void deskewOneSection(CImg<> &rawSection, float* nxp2OutBuff, int z, int nz,
// float *background, float backgroundExtra, float *slope, float inscale,
// int bUsecorr);
-#ifdef MRC
int saveIntermediateDataForDebugging(const ReconParams& params);
-#endif
void matrix_transpose(float* mat, int nRows, int nCols);
@@ -316,9 +305,7 @@ void writeResult(int it, int iw, const ReconParams& params,
const ImageParams& imgParams, const ReconData& reconData);
// This only works for MRC/DV files for now:
-#ifdef MRC
void saveCommandLineToHeader(int argc, char **argv, IW_MRC_HEADER &header);
-#endif
void dumpBands(std::vector* bands, int nx, int ny, int nz0);
diff --git a/src/cudaSirecon/mrc.h b/src/cudaSirecon/mrc.h
index b43e1e3..1b091f0 100644
--- a/src/cudaSirecon/mrc.h
+++ b/src/cudaSirecon/mrc.h
@@ -1,18 +1,6 @@
// MRC-specific functionality
#include "cudaSirecon.h"
-#include "IM.h"
-#include "IMInclude.h"
-#include "IWApiConstants.h"
-#if defined(_MSC_VER) && (_MSC_VER >= 1900)
-// for IMLIB with vs >2015
-// https://stackoverflow.com/questions/30412951/unresolved-external-symbol-imp-fprintf-and-imp-iob-func-sdl2
-FILE _iob[] = {*stdin, *stdout, *stderr};
-extern "C" FILE *__cdecl __iob_func(void)
-{
- return _iob;
-}
-#endif
// MRC header parser
void loadHeader(const ReconParams& params, ImageParams* imgParams,
diff --git a/src/dvfile.h b/src/dvfile.h
new file mode 100644
index 0000000..b661f0a
--- /dev/null
+++ b/src/dvfile.h
@@ -0,0 +1,547 @@
+#ifndef DVFILE_H
+#define DVFILE_H
+
+#include
+#include
+#include