Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions BioFVM/BioFVM_microenvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
*/

#include "BioFVM_microenvironment.h"
#include "BioFVM_utilities.h"
#include "BioFVM_solvers.h"
#include "BioFVM_vector.h"
#include <cmath>
Expand Down Expand Up @@ -1467,6 +1468,7 @@ void load_initial_conditions_from_csv(std::string filename)
// determine if header row exists
std::string line;
std::getline( file , line );
trim_cr(line);
char c = line.c_str()[0];
std::vector<int> substrate_indices;
bool header_provided = false;
Expand Down Expand Up @@ -1515,13 +1517,15 @@ void load_initial_conditions_from_csv(std::string filename)
file.close();
std::ifstream file(filename, std::ios::in);
std::getline(file, line);
trim_cr(line);
}

std::cout << "Loading substrate initial conditions from CSV file " << filename << " ... " << std::endl;
std::vector<int> voxel_set = {}; // set to check that no voxel value is set twice

while (std::getline(file, line))
{
trim_cr(line);
get_row_from_substrate_initial_condition_csv(voxel_set, line, substrate_indices, header_provided);
}

Expand Down
9 changes: 6 additions & 3 deletions BioFVM/BioFVM_utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,12 @@ void seed_random( void );
double uniform_random( void );

double compute_mean( std::vector<double>& values );
double compute_variance( std::vector<double>& values, double mean );
double compute_variance( std::vector<double>& values );

double compute_variance( std::vector<double>& values, double mean );
double compute_variance( std::vector<double>& values );

inline void trim_cr( std::string& line )
{ if (!line.empty() && line.back() == '\r') { line.pop_back(); } }
Comment thread
drbergman marked this conversation as resolved.

};

#endif
15 changes: 9 additions & 6 deletions core/PhysiCell_rules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1535,8 +1535,9 @@ void parse_csv_rules_v0( std::string filename )

while( fs.eof() == false )
{
std::string line;
std::getline( fs , line, '\n');
std::string line;
std::getline( fs , line, '\n');
trim_cr(line);
if( line.size() > 0 )
{ parse_csv_rule_v0(line); }
}
Expand Down Expand Up @@ -1671,8 +1672,9 @@ void parse_csv_rules_v1( std::string filename )

while( fs.eof() == false )
{
std::string line;
std::getline( fs , line, '\n');
std::string line;
std::getline( fs , line, '\n');
trim_cr(line);
if( line.size() > 0 )
{ parse_csv_rule_v1(line); }
}
Expand Down Expand Up @@ -1804,8 +1806,9 @@ void parse_csv_rules_v3( std::string filename )

while( fs.eof() == false )
{
std::string line;
std::getline( fs , line, '\n');
std::string line;
std::getline( fs , line, '\n');
trim_cr(line);
if( line.size() > 0 )
{ parse_csv_rule_v3(line); }
}
Expand Down
8 changes: 7 additions & 1 deletion modules/PhysiCell_geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ void load_cells_csv_v1( std::string filename )
std::string line;
while (std::getline(file, line))
{
trim_cr(line);
std::vector<double> data;
csv_to_vector( line.c_str() , data );

Expand Down Expand Up @@ -840,6 +841,7 @@ void load_cells_csv_v2( std::string filename )

std::string line;
std::getline( file , line );
trim_cr(line);

// tokenize the labels

Expand All @@ -848,7 +850,10 @@ void load_cells_csv_v2( std::string filename )
// process all remaining lines

while (std::getline(file, line))
{ process_csv_v2_line(line,labels); }
{
trim_cr(line);
process_csv_v2_line(line,labels);
}

// close the file

Expand All @@ -871,6 +876,7 @@ void load_cells_csv( std::string filename )
// determine version
std::string line;
std::getline( file , line );
trim_cr(line);
char c = line.c_str()[0];
Comment thread
drbergman marked this conversation as resolved.

file.close();
Expand Down
Loading