Applications/ScalarFiberAnalyzer/atlasmodel.cpp
// AtlasModel is for the csv match table between csv of T1/T2 images and csv of DTI deformation fields
AtlasModel is for the csv match table between csv of T1/T2 images and csv of DTI deformation fields
AtlasModel is for the csv match table between csv of T1 / T2 images and csv of DTI deformation fields
AtlasModel::AtlasModel(QObject *parent, std::map<std::string,tool::TractData> db1,
                       std::map<std::string,tool::TractData> db2) :
    QAbstractTableModel(parent)
{
    tract_db.clear();
    unordered_set<std::string> found;
    bool wflag = true;
    for(std::map<std::string,tool::TractData>::iterator it = db1.begin(); it!= db1.end(); ++it){
        std::string key = it->first;
        for(std::map<std::string,tool::TractData>::iterator itt = db2.begin(); itt!= db2.end(); ++itt){
            std::string mkey = itt->first;
            if(!found.empty() && found.find(mkey) != found.end()){
                if(wflag &&(key == mkey || mkey.find(key) != std::string::npos || key.find(mkey) != std::string::npos)){
                    wflag = false;
                    ErrorReporter::fire("Duplicate matches were found and eliminated!");
                }
                continue;
            }
            if(key == mkey){
                tool::MapData mapd = {
                    it->second.file_path,
                    itt->second.file_path,
                    QString::fromStdString(key),
                    QString::fromStdString(mkey)
                };
                tract_db.push_back(mapd);
                found.insert(mkey);
                break;
            }
            else if(key.length() <= mkey.length() && mkey.find(key) != std::string::npos){
                tool::MapData mapd = {
                    it->second.file_path,
                    itt->second.file_path,
                    QString::fromStdString(key),
                    QString::fromStdString(mkey)
                };
                tract_db.push_back(mapd);
                found.insert(mkey);
                break;
            }
            else if(mkey.length() < key.length() && key.find(mkey) != std::string::npos){
                tool::MapData mapd = {
                    it->second.file_path,
                    itt->second.file_path,
                    QString::fromStdString(key),
                    QString::fromStdString(mkey)
                };
                tract_db.push_back(mapd);
                found.insert(mkey);
                break;
            }
        }
    }
    checkedState = new Qt::CheckState[tract_db.size()]();
    for(unsigned int i =0; i< tract_db.size(); i++){
        checkedState[i] = Qt::Checked;
    }
}
AtlasModel :: AtlasModel ( QObject * parent , std :: map < std :: string , tool :: TractData > db1 , std :: map < std :: string , tool :: TractData > db2 ) : QAbstractTableModel ( parent ) { tract_db . clear ( ) ; unordered_set < std :: string > found ; bool wflag = true ; for ( std :: map < std :: string , tool :: TractData > :: iterator it = db1 . begin ( ) ; it != db1 . end ( ) ; ++ it ) { std :: string key = it -> first ; for ( std :: map < std :: string , tool :: TractData > :: iterator itt = db2 . begin ( ) ; itt != db2 . end ( ) ; ++ itt ) { std :: string mkey = itt -> first ; if ( ! found . empty ( ) && found . find ( mkey ) != found . end ( ) ) { if ( wflag && ( key == mkey || mkey . find ( key ) != std :: string :: npos || key . find ( mkey ) != std :: string :: npos ) ) { wflag = false ; ErrorReporter :: fire ( " " ) ; } continue ; } if ( key == mkey ) { tool :: MapData mapd = { it -> second . file_path , itt -> second . file_path , QString :: fromStdString ( key ) , QString :: fromStdString ( mkey ) } ; tract_db . push_back ( mapd ) ; found . insert ( mkey ) ; break ; } else if ( key . length ( ) <= mkey . length ( ) && mkey . find ( key ) != std :: string :: npos ) { tool :: MapData mapd = { it -> second . file_path , itt -> second . file_path , QString :: fromStdString ( key ) , QString :: fromStdString ( mkey ) } ; tract_db . push_back ( mapd ) ; found . insert ( mkey ) ; break ; } else if ( mkey . length ( ) < key . length ( ) && key . find ( mkey ) != std :: string :: npos ) { tool :: MapData mapd = { it -> second . file_path , itt -> second . file_path , QString :: fromStdString ( key ) , QString :: fromStdString ( mkey ) } ; tract_db . push_back ( mapd ) ; found . insert ( mkey ) ; break ; } } } checkedState = new Qt :: CheckState [ tract_db . size ( ) ] ( ) ; for ( unsigned int i = 0 ; i < tract_db . size ( ) ; i ++ ) { checkedState [ i ] = Qt :: Checked ; } }
AtlasModel is for the csv match table between csv of T1/T2 images and csv of DTI deformation fields
AtlasModel is for the csv match table between csv of T1 / T2 images and csv of DTI deformation fields
// store the union of db1 and db2 into vector // iteratively search data in DTI csv to match an DTI csv file id with an T1/T2 map csv file id. // matching conditions: s1 equal s2, or s1 contains s2, or s2 contains s1 // one id is supposed to be matched only once