Hamid R. Tizhoosh

295 papers A* 1B 52C 7Misc 1Journal 147Unranked 75
YearRankTypeTitle / Venue / Authors
2025 J jnl
CoRR
Sobhan Hemati, Ghazal Alabtah, Saghir Alfasly, Hamid R. Tizhoosh
2025 J jnl
CoRR
Saghir Alfasly, Ghazal Alabtah, Hamid R. Tizhoosh
2025 J jnl
CoRR
Saghir Alfasly, Wataru Uegami, MD Enamul Hoq, Ghazal Alabtah, Hamid R. Tizhoosh
2025 J jnl
CoRR
Hamid R. Tizhoosh
2024 J jnl
CoRR
Sobhan Hemati, Krishna R. Kalari, Hamid R. Tizhoosh
2024 J jnl
CoRR
Isaiah Lahr, Saghir Alfasly, Peyman Nejat, Jibran A. Khan, Luke Kottom, Vaishnavi Kumbhar, Areej Alsaafin, Abubakr Shafique, Sobhan Hemati, Ghazal Alabtah, Nneka I. Comfere, Dennis Murphree, Aaron Mangold, Saba Yasir, Chady Meroueh, Lisa Boardman, Vijay H. Shah, Joaquin J. Garcia, Hamid R. Tizhoosh
2024 J jnl
Comput. Oper. Res.
Davood Zaman Farsa, Shahryar Rahnamayan, Azam Asilian Bidgoli, Hamid R. Tizhoosh
2024 J jnl
CoRR
Hamid R. Tizhoosh
2024 J jnl
CoRR
Hamid R. Tizhoosh, Liron Pantanowitz
2024 J jnl
CoRR
Hamid R. Tizhoosh
2024 J jnl
CoRR
Areej Alsaafin, Abubakr Shafique, Saghir Alfasly, Hamid R. Tizhoosh
2024 A* conf
CVPR
Saghir Alfasly, Abubakr Shafique, Peyman Nejat, Jibran A. Khan, Areej Alsaafin, Ghazal Alabtah, Hamid R. Tizhoosh
2024 J jnl
CoRR
Areej Alsaafin, Peyman Nejat, Abubakr Shafique, Jibran A. Khan, Saghir Alfasly, Ghazal Alabtah, Hamid R. Tizhoosh
2024 J jnl
CoRR
Ehsan Rokhsatyazdi, Shahryar Rahnamayan, Sevil Zanjani Miyandoab, Azam Asilian Bidgoli, Hamid R. Tizhoosh
2024 J jnl
CoRR
Saghir Alfasly, Ghazal Alabtah, Sobhan Hemati, Krishna Rani Kalari, Hamid R. Tizhoosh
2023 J jnl
CoRR
Abubakr Shafique, Ricardo Gonzalez, Liron Pantanowitz, Puay Hoon Tan, Alberto Machado, Ian A. Cree, Hamid R. Tizhoosh
2023 conf
ICCV (Workshops)
Milad Sikaroudi, Seyedeh Maryam Hosseini, Shahryar Rahnamayan, Hamid R. Tizhoosh
2023 J jnl
CoRR
Milad Sikaroudi, Seyedeh Maryam Hosseini, Shahryar Rahnamayan, Hamid R. Tizhoosh
2023 J jnl
CoRR
Kimia Hemmatirad, Morteza Babaie, Jeffrey Hodgin, Liron Pantanowitz, Hamid R. Tizhoosh
2023 conf
EMBC
Seyedeh Maryam Hosseini, Abubakr Shafique, Morteza Babaie, Hamid R. Tizhoosh
2023 J jnl
CoRR
Milad Sikaroudi, Mehdi Afshari, Abubakr Shafique, Shivam Kalra, Hamid R. Tizhoosh
2023 conf
EMBC
Abubakr Shafique, Morteza Babaie, Ricardo Gonzalez, Adrian Batten, Soma Sikdar, Hamid R. Tizhoosh
2023 J jnl
CoRR
Abubakr Shafique, Morteza Babaie, Ricardo Gonzalez, Adrian Batten, Soma Sikdar, Hamid R. Tizhoosh
2023 J jnl
CoRR
Peyman Nejat, Areej Alsaafin, Ghazal Alabtah, Nneka I. Comfere, Aaron Mangold, Dennis Murphree, Patricija Zot, Saba Yasir, Joaquin J. Garcia, Hamid R. Tizhoosh
2023 conf
Digital and Computational Pathology
Areej Alsaafin, Morteza Babaie, Hamid R. Tizhoosh
2023 J jnl
CoRR
Azam Asilian Bidgoli, Shahryar Rahnamayan, Taher Dehkharghanian, Abtin Riasatian, Hamid R. Tizhoosh
2023 J jnl
IEEE Trans. Evol. Comput.
Azam Asilian Bidgoli, Shahryar Rahnamayan, Taher Dehkharghanian, Abtin Riasatian, Hamid R. Tizhoosh
2023 conf
EMBC
Abubakr Shafique, Morteza Babaie, Ricardo Gonzalez, Hamid R. Tizhoosh
2023 J jnl
CoRR
Abubakr Shafique, Morteza Babaie, Ricardo Gonzalez, Hamid R. Tizhoosh
2023 J jnl
Comput. Biol. Medicine
Sobhan Hemati, Shivam Kalra, Morteza Babaie, Hamid R. Tizhoosh
2023 J jnl
IEEE Trans. Medical Imaging
Seyedeh Maryam Hosseini, Milad Sikaroudi, Morteza Babaie, Hamid R. Tizhoosh
2023 J jnl
CoRR
Pooria Mazaheri, Azam Asilian Bidgoli, Shahryar Rahnamayan, Hamid R. Tizhoosh
2023 J jnl
Appl. Soft Comput.
Pooria Mazaheri, Azam Asilian Bidgoli, Shahryar Rahnamayan, Hamid R. Tizhoosh
2023 J jnl
CoRR
Saghir Alfasly, Abubakr Shafique, Peyman Nejat, Jibran A. Khan, Areej Alsaafin, Ghazal Alabtah, Hamid R. Tizhoosh
2023 J jnl
CoRR
Abubakr Shafique, Saghir Alfasly, Areej Alsaafin, Peyman Nejat, Jibran A. Khan, Hamid R. Tizhoosh
2023 conf
SSCI
Ehsan Rokhsatyazdi, Shahryar Rahnamayan, Sevil Zanjani Miyandoab, Azam Asilian Bidgoli, Hamid R. Tizhoosh
2023 J jnl
CoRR
Saghir Alfasly, Peyman Nejat, Sobhan Hemati, Jibran A. Khan, Isaiah Lahr, Areej Alsaafin, Abubakr Shafique, Nneka I. Comfere, Dennis Murphree, Chady Meroueh, Saba Yasir, Aaron Mangold, Lisa Boardman, Vijay H. Shah, Joaquin J. Garcia, Hamid R. Tizhoosh
2023 J jnl
Comput. Biol. Medicine
Youqing Mu, Hamid R. Tizhoosh, Taher Dehkharghanian, Clinton J. V. Campbell
2022 J jnl
Comput. Vis. Image Underst.
Sobhan Hemati, Mohammad Hadi Mehdizavareh, Shoja'eddin Chenouri, Hamid R. Tizhoosh
2022 J jnl
Pattern Recognit. Lett.
Sobhan Hemati, Hamid R. Tizhoosh
2022 J jnl
CoRR
Seyedeh Maryam Hosseini, Milad Sikaroudi, Morteza Babaie, Hamid R. Tizhoosh
2022 conf
DeCaF/FAIR@MICCAI
Seyedeh Maryam Hosseini, Milad Sikaroudi, Morteza Babaie, Hamid R. Tizhoosh
2022 J jnl
Artif. Intell. Medicine
Azam Asilian Bidgoli, Shahryar Rahnamayan, Taher Dehkharghanian, Abtin Riasatian, Shivam Kalra, Manit Zaveri, Clinton J. V. Campbell, Anil Parwani, Liron Pantanowitz, Hamid R. Tizhoosh
2022 conf
EMBC
Milad Sikaroudi, Shahryar Rahnamayan, Hamid R. Tizhoosh
2022 J jnl
CoRR
Milad Sikaroudi, Shahryar Rahnamayan, Hamid R. Tizhoosh
2022 conf
MIDL
Danial Maleki, Hamid R. Tizhoosh
2022 J jnl
CoRR
Danial Maleki, Hamid R. Tizhoosh
2022 J jnl
CoRR
Sobhan Hemati, Shivam Kalra, Morteza Babaie, Hamid R. Tizhoosh
2022 J jnl
CoRR
Amir Safarpoor, Jason D. Hipp, Hamid R. Tizhoosh
2022 J jnl
CoRR
Mohammed Adnan, Yani A. Ioannou, Chuan-Yung Tsai, Angus Galloway, Hamid R. Tizhoosh, Graham W. Taylor
2022 J jnl
IEEE J. Biomed. Health Informatics
Maral Rasoolijaberi, Morteza Babaie, Abtin Riasatian, Sobhan Hemati, Parsa Ashrafi, Ricardo Gonzalez, Hamid R. Tizhoosh
2022 conf
ICHI
Kimia Hemmatirad, Morteza Babaie, Mehdi Afshari, Danial Maleki, Mahjabin Saiadi, Hamid R. Tizhoosh
2021 conf
EMBC
Mehdi Afshari, Hamid R. Tizhoosh
2021 J jnl
CoRR
Mehdi Afshari, Hamid R. Tizhoosh
2021 B conf
ICIP
Sobhan Hemati, Mohammad Hadi Mehdizavareh, Morteza Babaie, Shivam Kalra, Hamid R. Tizhoosh
2021 conf
EMBC
Aishwarya Krishna Allada, Yuanxin Wang, Veni Jindal, Morteza Babaie, Hamid R. Tizhoosh, Mark Crowley
2021 conf
EMBC
Abubakr Shafique, Morteza Babaie, Mahjabin Sajadi, Adrian Batten, Soma Skdar, Hamid R. Tizhoosh
2021 J jnl
CoRR
Abubakr Shafique, Morteza Babaie, Mahjabin Sajadi, Adrian Batten, Soma Skdar, Hamid R. Tizhoosh
2021 J jnl
CoRR
Sobhan Hemati, Hamid R. Tizhoosh
2021 conf
MIDL
Sobhan Hemati, Shivam Kalra, Cameron Meaney, Morteza Babaie, Ali Ghodsi, Hamid R. Tizhoosh
2021 J jnl
CoRR
Sobhan Shafiei, Morteza Babaie, Shivam Kalra, Hamid R. Tizhoosh
2021 J jnl
Medical Image Anal.
Abtin Riasatian, Morteza Babaie, Danial Maleki, Shivam Kalra, Mojtaba Valipour, Sobhan Hemati, Manit Zaveri, Amir Safarpoor, Sobhan Shafiei, Mehdi Afshari, Maral Rasoolijaberi, Milad Sikaroudi, Mohd Adnan, Sultaan Shah, Charles Choi, Savvas Damaskinos, Clinton J. V. Campbell, Phedias Diamandis, Liron Pantanowitz, Hany Kashani, Ali Ghodsi, Hamid R. Tizhoosh
2021 J jnl
CoRR
Shalev Lifshitz, Abtin Riasatian, Hamid R. Tizhoosh
2021 J jnl
CoRR
Rohollah Moosavi Tayebi, Youqing Mu, Taher Dehkharghanian, Catherine Ross, Monalisa Sur, Ronan Foley, Hamid R. Tizhoosh, Clinton J. V. Campbell
2021 C conf
BIBE
Seyedeh Maryam Hosseini, Morteza Babaie, Hamid R. Tizhoosh
2021 conf
ISBI
Milad Sikaroudi, Benyamin Ghojogh, Fakhri Karray, Mark Crowley, Hamid R. Tizhoosh
2021 J jnl
CoRR
Milad Sikaroudi, Benyamin Ghojogh, Fakhri Karray, Mark Crowley, Hamid R. Tizhoosh
2021 conf
MICCAI (8)
Shivam Kalra, Mohammed Adnan, Sobhan Hemati, Taher Dehkharghanian, Shahryar Rahnamayan, Hamid R. Tizhoosh
2021 J jnl
CoRR
Shivam Kalra, Mohammed Adnan, Sobhan Hemati, Taher Dehkharghanian, Shahryar Rahnamayan, Hamid R. Tizhoosh
2021 J jnl
CoRR
Shivam Kalra, Junfeng Wen, Jesse C. Cresswell, Maksims Volkovs, Hamid R. Tizhoosh
2021 J jnl
CoRR
Antonio Sze-To, Abtin Riasatian, Hamid R. Tizhoosh
2021 conf
EMBC
Nitish Bhatt, David Ramon Prados, Nedim Hodzic, Christos Karanassios, Hamid R. Tizhoosh
2021 J jnl
CoRR
Nitish Bhatt, David Ramon Prados, Nedim Hodzic, Christos Karanassios, Hamid R. Tizhoosh
2020 B conf
IJCNN
Abtin Riasatian, Maral Rasoolijaberi, Morteza Babaie, Hamid R. Tizhoosh
2020 J jnl
CoRR
Abtin Riasatian, Maral Rasoolijaberi, Morteza Babaie, Hamid R. Tizhoosh
2020 B conf
AIME
Morteza Babaie, Hany Kashani, Meghana Dinesh Kumar, Hamid R. Tizhoosh
2020 J jnl
CoRR
Morteza Babaie, Hany Kashani, Meghana Dinesh Kumar, Hamid R. Tizhoosh
2020 J jnl
CoRR
Sobhan Hemati, Mohammad Hadi Mehdizavareh, Shoja'eddin Chenouri, Hamid R. Tizhoosh
2020 B conf
ICPR
Milad Sikaroudi, Benyamin Ghojogh, Fakhri Karray, Mark Crowley, Hamid R. Tizhoosh
2020 J jnl
CoRR
Milad Sikaroudi, Benyamin Ghojogh, Fakhri Karray, Mark Crowley, Hamid R. Tizhoosh
2020 J jnl
IEEE Trans. Medical Imaging
Sobhan Shafiei, Amir Safarpoor, Ahad Jamalizadeh, Hamid R. Tizhoosh
2020 J jnl
IEEE Access
Arash Ebrahimian, Hossein Mohammadi, Morteza Babaie, Nima Maftoon, Hamid R. Tizhoosh
2020 conf
EMBC
Abdullah Irfan, Akash L. Adivishnu, Antonio Sze-To, Taher Dehkharghanian, Shahryar Rahnamayan, Hamid R. Tizhoosh
2020 conf
EMBC
Taher Dehkharghanian, Shahryar Rahnamayan, Hamid R. Tizhoosh
2020 B conf
IJCNN
Benyamin Ghojogh, Milad Sikaroudi, Sobhan Shafiei, Hamid R. Tizhoosh, Fakhri Karray, Mark Crowley
2020 J jnl
CoRR
Benyamin Ghojogh, Milad Sikaroudi, Sobhan Shafiei, Hamid R. Tizhoosh, Fakhri Karray, Mark Crowley
2020 B conf
AIME
Aditya Sriram, Shivam Kalra, Morteza Babaie, Brady Kieffer, Waddah Al Drobi, Shahryar Rahnamayan, Hany Kashani, Hamid R. Tizhoosh
2020 J jnl
CoRR
Aditya Sriram, Shivam Kalra, Morteza Babaie, Brady Kieffer, Waddah Al Drobi, Shahryar Rahnamayan, Hany Kashani, Hamid R. Tizhoosh
2020 conf
ISVC (1)
Danial Maleki, Mehdi Afshari, Morteza Babaie, Hamid R. Tizhoosh
2020 J jnl
CoRR
Danial Maleki, Mehdi Afshari, Morteza Babaie, Hamid R. Tizhoosh
2020 B conf
ICTAI
Manit Zaveri, Sobhan Hemati, Sultaan Shah, Savvas Damaskinos, Hamid R. Tizhoosh
2020 conf
ECCV (29)
Shivam Kalra, Mohammed Adnan, Graham W. Taylor, Hamid R. Tizhoosh
2020 conf
ISVC (1)
Milad Sikaroudi, Benyamin Ghojogh, Amir Safarpoor, Fakhri Karray, Mark Crowley, Hamid R. Tizhoosh
2020 J jnl
CoRR
Milad Sikaroudi, Benyamin Ghojogh, Amir Safarpoor, Fakhri Karray, Mark Crowley, Hamid R. Tizhoosh
2020 J jnl
npj Digit. Medicine
Shivam Kalra, Hamid R. Tizhoosh, Sultaan Shah, Charles Choi, Savvas Damaskinos, Amir Safarpoor, Sobhan Shafiei, Morteza Babaie, Phedias Diamandis, Clinton J. V. Campbell, Liron Pantanowitz
2020 conf
EMBC
Manit Zaveri, Shivam Kalra, Morteza Babaie, Sultaan Shah, Savvas Damaskinos, Hany Kashani, Hamid R. Tizhoosh
2020 J jnl
CoRR
Manit Zaveri, Shivam Kalra, Morteza Babaie, Sultaan Shah, Savvas Damaskinos, Hany Kashani, Hamid R. Tizhoosh
2020 conf
CVPR Workshops
Mohammed Adnan, Shivam Kalra, Hamid R. Tizhoosh
2020 J jnl
CoRR
Mohammed Adnan, Shivam Kalra, Hamid R. Tizhoosh
2020 B conf
AIME
Antonio Sze-To, Hamid R. Tizhoosh
2020 J jnl
CoRR
Antonio Sze-To, Hamid R. Tizhoosh
2020 conf
ICIAR (2)
Alison K. Cheeseman, Hamid R. Tizhoosh, Edward R. Vrscay
2020 conf
EMBC
Milad Sikaroudi, Amir Safarpoor, Benyamin Ghojogh, Sobhan Shafiei, Mark Crowley, Hamid R. Tizhoosh
2020 J jnl
CoRR
Milad Sikaroudi, Amir Safarpoor, Benyamin Ghojogh, Sobhan Shafiei, Mark Crowley, Hamid R. Tizhoosh
2020 conf
ICIAR (2)
Benyamin Ghojogh, Milad Sikaroudi, Hamid R. Tizhoosh, Fakhri Karray, Mark Crowley
2020 J jnl
CoRR
Benyamin Ghojogh, Milad Sikaroudi, Hamid R. Tizhoosh, Fakhri Karray, Mark Crowley
2019 conf
ICIAR (2)
Alison K. Cheeseman, Hamid R. Tizhoosh, Edward R. Vrscay
2019 J jnl
CoRR
Alison K. Cheeseman, Hamid R. Tizhoosh, Edward R. Vrscay
2019 conf
BHI
Sara Ross-Howe, Hamid R. Tizhoosh
2019 J jnl
CoRR
Sara Ross-Howe, Hamid R. Tizhoosh
2019 J jnl
CoRR
Shivam Kalra, Larry Li, Hamid R. Tizhoosh
2019 conf
ECDP
Morteza Babaie, Hamid R. Tizhoosh
2019 J jnl
CoRR
Morteza Babaie, Hamid R. Tizhoosh
2019 J jnl
IEEE Access
Hamed Erfankhah, Mehran Yazdi, Morteza Babaie, Hamid R. Tizhoosh
2019 J jnl
CoRR
Shivam Kalra, Mohammed Adnan, Graham W. Taylor, Hamid R. Tizhoosh
2019 J jnl
CoRR
Shivam Kalra, Hamid R. Tizhoosh, Sultaan Shah, Charles Choi, Savvas Damaskinos, Amir Safarpoor, Sobhan Shafiei, Morteza Babaie, Phedias Diamandis, Clinton J. V. Campbell, Liron Pantanowitz
2019 conf
ECDP
Wafa Chenni, Habib Herbi, Morteza Babaie, Hamid R. Tizhoosh
2019 J jnl
CoRR
Wafa Chenni, Habib Herbi, Morteza Babaie, Hamid R. Tizhoosh
2019 B conf
IJCNN
Aditya Sriram, Shivam Kalra, Hamid R. Tizhoosh
2019 J jnl
CoRR
Aditya Sriram, Shivam Kalra, Hamid R. Tizhoosh
2019 conf
IPTA
Hamid R. Tizhoosh, Shivam Kalra, Shalev Lifshitz, Morteza Babaie
2019 J jnl
CoRR
Hamid R. Tizhoosh, Shivam Kalra, Shalev Lifshitz, Morteza Babaie
2019 J jnl
CoRR
Shivam Kalra, Charles Choi, Sultaan Shah, Liron Pantanowitz, Hamid R. Tizhoosh
2018 conf
SSCI
Aravind Ravi, Harshwin Venugopal, Sruthy Paul, Hamid R. Tizhoosh
2018 J jnl
CoRR
Aravind Ravi, Harshwin Venugopal, Sruthy Paul, Hamid R. Tizhoosh
2018 J jnl
Expert Syst. Appl.
Amin Khatami, Morteza Babaie, Hamid R. Tizhoosh, Abbas Khosravi, Thanh Nguyen, Saeid Nahavandi
2018 J jnl
CoRR
Graham Bleaney, Matthew Kuzyk, Julian Man, Hossein Mayanloo, Hamid R. Tizhoosh
2018 C conf
IEA/AIE
Graham Bleaney, Matthew Kuzyk, Julian Man, Hossein Mayanloo, Hamid R. Tizhoosh
2018 conf
CCECE
Hojjat Salehinejad, Shahryar Rahnamayan, Hamid R. Tizhoosh
2018 B conf
IJCNN
Taha J. Alhindi, Shivam Kalra, Ka Hin Ng, Anika Afrin, Hamid R. Tizhoosh
2018 B conf
IJCNN
Meghana Dinesh Kumar, Morteza Babaie, Hamid R. Tizhoosh
2018 J jnl
CoRR
Meghana Dinesh Kumar, Morteza Babaie, Hamid R. Tizhoosh
2018 conf
SSCI
Dhruv Sharma, Sarim Zafar, Morteza Babaie, Hamid R. Tizhoosh
2018 J jnl
CoRR
Dhruv Sharma, Sarim Zafar, Morteza Babaie, Hamid R. Tizhoosh
2018 J jnl
J. Vis. Commun. Image Represent.
Shujin Zhu, Yuehua Li, Shivam Kalra, Hamid R. Tizhoosh
2018 J jnl
Appl. Soft Comput.
Amin Khatami, Morteza Babaie, Abbas Khosravi, Hamid R. Tizhoosh, Saeid Nahavandi
2018 J jnl
IEEE Trans. Biomed. Eng.
Hamid R. Tizhoosh, Morteza Babaie
2018 B conf
IJCNN
Sara Ross-Howe, Hamid R. Tizhoosh
2018 J jnl
CoRR
Sara Ross-Howe, Hamid R. Tizhoosh
2017 J jnl
CoRR
Meghana Dinesh Kumar, Morteza Babaie, Shujin Zhu, Shivam Kalra, Hamid R. Tizhoosh
2017 conf
SSCI
Meghana Dinesh Kumar, Morteza Babaie, Shujin Zhu, Shivam Kalra, Hamid R. Tizhoosh
2017 conf
CCECE
Amin Khatami, Morteza Babaie, Abbas Khosravi, Hamid R. Tizhoosh, Syed Moshfeq Salaken, Saeid Nahavandi
2017 conf
CVPR Workshops
Morteza Babaie, Shivam Kalra, Aditya Sriram, Christopher Mitcheltree, Shujin Zhu, Amin Khatami, Shahryar Rahnamayan, Hamid R. Tizhoosh
2017 J jnl
CoRR
Morteza Babaie, Shivam Kalra, Aditya Sriram, Christopher Mitcheltree, Shujin Zhu, Amin Khatami, Shahryar Rahnamayan, Hamid R. Tizhoosh
2017 J jnl
CoRR
Hamed Erfankhah, Mehran Yazdi, Hamid R. Tizhoosh
2017 conf
SSCI
Hamed Erfankhah, Mehran Yazdi, Hamid R. Tizhoosh
2017 J jnl
CoRR
Brady Kieffer, Morteza Babaie, Shivam Kalra, Hamid R. Tizhoosh
2017 conf
IPTA
Brady Kieffer, Morteza Babaie, Shivam Kalra, Hamid R. Tizhoosh
2017 J jnl
CoRR
Hamid R. Tizhoosh, Gregory J. Czarnota
2017 J jnl
CoRR
Aditya Sriram, Shivam Kalra, Hamid R. Tizhoosh, Shahryar Rahnamayan
2017 conf
SSCI
Aditya Sriram, Shivam Kalra, Hamid R. Tizhoosh, Shahryar Rahnamayan
2017 J jnl
CoRR
Morteza Babaie, Hamid R. Tizhoosh, Amin Khatami, Mohammad Ebrahim Shiri
2017 conf
IPTA
Morteza Babaie, Hamid R. Tizhoosh, Amin Khatami, Mohammad Ebrahim Shiri
2017 J jnl
Appl. Soft Comput.
Hojjat Salehinejad, Shahryar Rahnamayan, Hamid R. Tizhoosh
2017 J jnl
CoRR
Hojjat Salehinejad, Shahryar Rahnamayan, Hamid R. Tizhoosh
2017 conf
SSCI
Hojjat Salehinejad, Shahryar Rahnamayan, Hamid R. Tizhoosh
2017 J jnl
CoRR
Morteza Babaie, Hamid R. Tizhoosh, Shujin Zhu, Mohammad Ebrahim Shiri
2017 C conf
ICPRAM
Morteza Babaie, Hamid R. Tizhoosh, Shujin Zhu, Mohammad Ebrahim Shiri
2017 J jnl
CoRR
Bill S. Lin, Kevin Michael, Shivam Kalra, Hamid R. Tizhoosh
2017 conf
SSCI
Bill S. Lin, Kevin Michael, Shivam Kalra, Hamid R. Tizhoosh
2017 J jnl
CoRR
Mehrdad J. Gangeh, Hamid R. Tizhoosh, Kan Wu, Dun Huang, Hadi Tadayyon, Gregory J. Czarnota
2017 conf
BHI
Mehrdad J. Gangeh, Hamid R. Tizhoosh, Kan Wu, Dun Huang, Hadi Tadayyon, Gregory J. Czarnota
2016 J jnl
CoRR
Hamid R. Tizhoosh, Ahmed A. Othman
2016 B conf
Image Processing
Hamid R. Tizhoosh, Ahmed A. Othman
2016 J jnl
CoRR
Fares S. Al-Qunaieer, Hamid R. Tizhoosh, Shahryar Rahnamayan
2016 J jnl
CoRR
Hamid R. Tizhoosh, Christopher Mitcheltree, Shujin Zhu, Shamak Dutta
2016 B conf
ICPR
Hamid R. Tizhoosh, Christopher Mitcheltree, Shujin Zhu, Shamak Dutta
2016 J jnl
CoRR
Antonio Sze-To, Hamid R. Tizhoosh, Andrew K. C. Wong
2016 B conf
IJCNN
Antonio Sze-To, Hamid R. Tizhoosh, Andrew K. C. Wong
2016 J jnl
CoRR
Hamid R. Tizhoosh, Shahryar Rahnamayan
2016 B conf
CEC
Hamid R. Tizhoosh, Shahryar Rahnamayan
2016 B conf
CEC
Hojjat Salehinejad, Shahryar Rahnamayan, Hamid R. Tizhoosh
2016 J jnl
CoRR
Mina Nouredanesh, Hamid R. Tizhoosh, Ershad Banijamali
2016 B conf
ICIP
Mina Nouredanesh, Hamid R. Tizhoosh, Ershad Banijamali
2016 J jnl
CoRR
Xinran Liu, Hamid R. Tizhoosh, Jonathan Kofman
2016 B conf
IJCNN
Xinran Liu, Hamid R. Tizhoosh, Jonathan Kofman
2016 J jnl
CoRR
Shivam Kalra, Aditya Sriram, Shahryar Rahnamayan, Hamid R. Tizhoosh
2016 B conf
ICPR
Shivam Kalra, Aditya Sriram, Shahryar Rahnamayan, Hamid R. Tizhoosh
2016 conf
ISVC (1)
Hamid R. Tizhoosh, Shujin Zhu, Hanson Lo, Varun Chaudhari, Tahmid Mehdi
2016 J jnl
CoRR
Hamid R. Tizhoosh, Shujin Zhu, Hanson Lo, Varun Chaudhari, Tahmid Mehdi
2016 J jnl
CoRR
Shujin Zhu, Hamid R. Tizhoosh
2016 B conf
IJCNN
Shujin Zhu, Hamid R. Tizhoosh
2016 J jnl
CoRR
Mina Nouredanesh, Hamid R. Tizhoosh, Ershad Banijamali, James Tung
2016 B conf
ICPR
Mina Nouredanesh, Hamid R. Tizhoosh, Ershad Banijamali, James Tung
2016 J jnl
J. Digit. Imaging
Farzad Khalvati, Aryan Salmanpour, Shahryar Rahnamayan, Masoom A. Haider, Hamid R. Tizhoosh
2016 conf
ISVC (1)
S. Sharma, I. Umar, L. Ospina, D. Wong, Hamid R. Tizhoosh
2016 J jnl
CoRR
S. Sharma, I. Umar, L. Ospina, D. Wong, Hamid R. Tizhoosh
2016 J jnl
CoRR
Hamid R. Tizhoosh, Mehrdad J. Gangeh, Hadi Tadayyon, Gregory J. Czarnota
2016 conf
ISBI
Hamid R. Tizhoosh, Mehrdad J. Gangeh, Hadi Tadayyon, Gregory J. Czarnota
2015 J jnl
CoRR
Zehra Camlica, Hamid R. Tizhoosh, Farzad Khalvati
2015 conf
IPTA
Zehra Camlica, Hamid R. Tizhoosh, Farzad Khalvati
2015 J jnl
CoRR
Hamid R. Tizhoosh
2015 B conf
ICIP
Hamid R. Tizhoosh
2015 J jnl
CoRR
Ahmed A. Othman, Hamid R. Tizhoosh, Farzad Khalvati
2015 J jnl
CoRR
Hamid R. Tizhoosh, Shahryar Rahnamayan
2015 B conf
FUZZ-IEEE
Hamid R. Tizhoosh, Shahryar Rahnamayan
2015 C conf
ICMLA
Zehra Camlica, Hamid R. Tizhoosh, Farzad Khalvati
2015 J jnl
CoRR
Zehra Camlica, Hamid R. Tizhoosh, Farzad Khalvati
2015 J jnl
CoRR
Hojjat Salehinejad, Shahryar Rahnamayan, Hamid R. Tizhoosh
2015 C conf
ICMLA
Ahmed A. Othman, Hamid R. Tizhoosh, Farzad Khalvati
2015 J jnl
CoRR
Ahmed A. Othman, Hamid R. Tizhoosh, Farzad Khalvati
2015 J jnl
J. Real Time Image Process.
Farzad Khalvati, Mark D. Aagaard, Hamid R. Tizhoosh
2014 J jnl
IEEE Trans. Fuzzy Syst.
Ahmed A. Othman, Hamid R. Tizhoosh, Farzad Khalvati
2014 B conf
IEEE Congress on Evolutionary Computation
Hojjat Salehinejad, Shahryar Rahnamayan, Hamid R. Tizhoosh, Stephen Y. Chen
2014 J jnl
J. Digit. Imaging
Fares S. Al-Qunaieer, Hamid R. Tizhoosh, Shahryar Rahnamayan
2014 J jnl
Inf. Sci.
Masoud Mahootchi, Hamid R. Tizhoosh, Kumaraswamy Ponnambalam
2014 B conf
IEEE Congress on Evolutionary Computation
Hojjat Salehinejad, Shahryar Rahnamayan, Hamid R. Tizhoosh
2013 conf
IFSA/NAFIPS
Ahmed A. Othman, Hamid R. Tizhoosh
2013 conf
EMBC
Zeinab Jahed, Khaled B. Shaban, Hamid R. Tizhoosh
2013 B conf
FUZZ-IEEE
Ahmed A. Othman, Hamid R. Tizhoosh
2011 J jnl
J. Digit. Imaging
Samar Samir Mohamed, J. M. Li, Magdy M. A. Salama, George H. Freeman, Hamid R. Tizhoosh, Aaron Fenster, K. Rizkalla
2011 Misc conf
AIAI
Farzad Khalvati, Mehdi Kianpour, Hamid R. Tizhoosh
2011 B conf
FUZZ-IEEE
Ahmed A. Othman, Hamid R. Tizhoosh
2011 B conf
ICIP
Fares S. Al-Qunaieer, Hamid R. Tizhoosh, Shahryar Rahnamayan
2011 B conf
IJCNN
Ahmed A. Othman, Hamid R. Tizhoosh
2011 C conf
EANN
Ahmed A. Othman, Hamid R. Tizhoosh
2010 conf
ICANN (1)
Ahmed A. Othman, Hamid R. Tizhoosh
2010 J jnl
Appl. Soft Comput.
Mario Ventresca, Shahryar Rahnamayan, Hamid R. Tizhoosh
2010 J jnl
Fuzzy Sets Syst.
Humberto Bustince Sola, Miguel Pagola, Edurne Barrenechea Tartas, Javier Fernández, Pedro Melo-Pinto, Pedro Couto, Hamid R. Tizhoosh, Javier Montero
2010 C conf
ISDA
Ahmed A. Othman, Hamid R. Tizhoosh
2010 conf
ACIVS (1)
Ahmed A. Othman, Hamid R. Tizhoosh
2010 B conf
IJCNN
Fares S. Al-Qunaieer, Hamid R. Tizhoosh, Shahryar Rahnamayan
2010 B conf
FUZZ-IEEE
Fares S. Al-Qunaieer, Hamid R. Tizhoosh, Shahryar Rahnamayan
2010 B conf
IEEE Congress on Evolutionary Computation
Soumya Banerjee, Hamid R. Tizhoosh
2009 conf
CIIP
Hamid R. Tizhoosh
2009 conf
CIIP
Farzad Khalvati, Hamid R. Tizhoosh
2009 J jnl
J. Adv. Comput. Intell. Intell. Informatics
Shahryar Rahnamayan, Hamid R. Tizhoosh, Magdy M. A. Salama
2009 B conf
IJCNN
Mario Ventresca, Hamid R. Tizhoosh
2009 conf
ICIAR
Farzad Khalvati, Hamid R. Tizhoosh, Arsen R. Hajian
2009 conf
IFSA/EUSFLAT Conf.
Miguel Pagola, Edurne Barrenechea Tartas, Aranzazu Jurio, Mikel Galar, Pedro Couto, Farhang Sahba, Hamid R. Tizhoosh
2009 conf
IFSA/EUSFLAT Conf.
Hamid R. Tizhoosh
2009 J jnl
Appl. Soft Comput.
Maryam Shokri, Hamid R. Tizhoosh, Mohamed S. Kamel
2009 B conf
FUZZ-IEEE
Hamid R. Tizhoosh, Farhang Sahba
2008 J jnl
Inf. Sci.
Mario Ventresca, Hamid R. Tizhoosh
2008 J jnl
Expert Syst. Appl.
Farhang Sahba, Hamid R. Tizhoosh, Magdy M. A. Salama
2008 J jnl
Appl. Soft Comput.
Maryam Shokri, Hamid R. Tizhoosh
2008 J jnl
BMC Medical Imaging
Farhang Sahba, Hamid R. Tizhoosh, Magdy M. A. Salama
2008 ch.
Oppositional Concepts in Computational Intelligence
Shahryar Rahnamayan, Hamid R. Tizhoosh
2008 B conf
FUZZ-IEEE
Kaveh Houshmand, Hamid R. Tizhoosh
2008 B conf
IEEE Congress on Evolutionary Computation
Shahryar Rahnamayan, Hamid R. Tizhoosh
2008 J jnl
Pattern Recognit.
Hamid R. Tizhoosh
2008 ch.
Oppositional Concepts in Computational Intelligence
Hamid R. Tizhoosh, Mario Ventresca
2008 B conf
IJCNN
Mario Ventresca, Hamid R. Tizhoosh
2008 ch.
Oppositional Concepts in Computational Intelligence
Farhang Sahba, Hamid R. Tizhoosh
2008 ch.
Oppositional Concepts in Computational Intelligence
Masoud Mahootchi, Hamid R. Tizhoosh, Kumaraswamy Ponnambalam
2008 J jnl
Appl. Soft Comput.
Shahryar Rahnamayan, Hamid R. Tizhoosh, Magdy M. A. Salama
2008 ch.
Oppositional Concepts in Computational Intelligence
Hamid R. Tizhoosh, Mario Ventresca, Shahryar Rahnamayan
2008 J jnl
IEEE Trans. Evol. Comput.
Shahryar Rahnamayan, Hamid R. Tizhoosh, Magdy M. A. Salama
2008 book
Oppositional Concepts in Computational Intelligence
Hamid R. Tizhoosh, Mario Ventresca
2008 ch.
Oppositional Concepts in Computational Intelligence
Maryam Shokri, Hamid R. Tizhoosh, Mohamed S. Kamel
2008 B conf
IJCNN
Maryam Shokri, Hamid R. Tizhoosh, Mohamed S. Kamel
2008 ch.
Oppositional Concepts in Computational Intelligence
Mario Ventresca, Hamid R. Tizhoosh
2008 ch.
Fuzzy Sets and Their Extensions: Representation, Aggregation and Models
Hamid R. Tizhoosh
2007 J jnl
Comput. Math. Appl.
Shahryar Rahnamayan, Hamid R. Tizhoosh, Magdy M. A. Salama
2007 B conf
SMC
Xianghai Wu, Jonathan Kofman, Hamid R. Tizhoosh
2007 conf
SIS
Alice R. Malisia, Hamid R. Tizhoosh
2007 J jnl
IEEE Trans. Fuzzy Syst.
Andrew Hamilton-Wright, Daniel W. Stashuk, Hamid R. Tizhoosh
2007 conf
FOCI
Mario Ventresca, Hamid R. Tizhoosh
2007 conf
FOCI
Shahryar Rahnamayan, Hamid R. Tizhoosh, Magdy M. A. Salama
2007 B conf
IEEE Congress on Evolutionary Computation
Shahryar Rahnamayan, Hamid R. Tizhoosh, Magdy M. A. Salama
2007 conf
FOCI
Mario Ventresca, Hamid R. Tizhoosh
2006 B conf
IJCNN
Farhang Sahba, Hamid R. Tizhoosh, Magdy M. A. Salama
2006 B conf
ICIP
Alice R. Malisia, Hamid R. Tizhoosh
2006 J jnl
J. Intell. Fuzzy Syst.
Jialin Song, Hamid R. Tizhoosh
2006 B conf
ICIP
Ehsan Mohammadi Arvacheh, Hamid R. Tizhoosh
2006 conf
CRV
Alice R. Malisia, Hamid R. Tizhoosh
2006 conf
IPCV
Shahryar Rahnamayan, Hamid R. Tizhoosh, Magdy M. A. Salama
2006 B conf
IJCNN
Mario Ventresca, Hamid R. Tizhoosh
2006 B conf
ICIP
Farhang Sahba, Hamid R. Tizhoosh, Magdy M. A. Salama
2006 J jnl
Pattern Anal. Appl.
Hamid R. Tizhoosh, Rozita A. Dara
2006 B conf
IEEE Congress on Evolutionary Computation
Shahryar Rahnamayan, Hamid R. Tizhoosh, Magdy M. A. Salama
2006 B conf
IEEE Congress on Evolutionary Computation
Shahryar Rahnamayan, Hamid R. Tizhoosh, Magdy M. A. Salama
2006 B conf
IJCNN
Maryam Shokri, Hamid R. Tizhoosh, Mohamed Kamel
2006 J jnl
J. Adv. Comput. Intell. Intell. Informatics
Hamid R. Tizhoosh
2006 J jnl
Int. J. Image Graph.
Hamid R. Tizhoosh, Graham W. Taylor
2006 B conf
ICIP
Shahryar Rahnamayan, Hamid R. Tizhoosh, Magdy M. A. Salama
2005 conf
ICIAR
Shahryar Rahnamayan, Hamid R. Tizhoosh, Magdy M. A. Salama
2005 J jnl
Pattern Recognit.
Hamid R. Tizhoosh
2005 conf
CIMCA/IAWTIC
Hamid R. Tizhoosh
2005 conf
ICIP (2)
Farhang Sahba, Hamid R. Tizhoosh, Magdy M. A. Salama
2005 conf
ICIAR
P. Ensafi, Hamid R. Tizhoosh
2005 conf
Computational Intelligence
Farhang Sahba, Hamid R. Tizhoosh, Magdy M. A. Salama
2004 conf
CRV
Maryam Shokri, Hamid R. Tizhoosh
2002 conf
ICIP (1)
Hamid R. Tizhoosh
2001 B conf
FUZZ-IEEE
Hamid R. Tizhoosh
2001 J jnl
Image Vis. Comput.
Hamid R. Tizhoosh, Gerald Krell, Bernd Michaelis
2000
Hamid R. Tizhoosh
2000 ch.
Computer Vision and Applications
Horst Haußecker, Hamid R. Tizhoosh
1998 J jnl
Int. J. Medical Informatics
Gerald Krell, Hamid R. Tizhoosh, Tilo Lilienblum, C. J. Moore, Bernd Michaelis
1998 conf
GI Jahrestagung
Hamid R. Tizhoosh
1997 conf
ICIP (2)
Hamid R. Tizhoosh, Gerald Krell, Bernd Michaelis
1997 B conf
CBMS
Gerald Krell, Hamid R. Tizhoosh, Tilo Lilienblum, C. J. Moore, Bernd Michaelis
1997 conf
ICNN
Gerald Krell, Hamid R. Tizhoosh, Tilo Lilienblum, C. J. Moore, Bernd Michaelis
1997 book
Fuzzy-Bildverarbeitung - Einführung in Theorie und Praxis.
Hamid R. Tizhoosh
1997 conf
Fuzzy Days
Hamid R. Tizhoosh, Gerald Krell, Bernd Michaelis
s3-storage/s3_uploader.py
← Index s3-storage/s3_uploader.py python
# python s3_uploader.py /path/to/files repository_name --notes "Optional notes"
import hashlib
import multiprocessing
from multiprocessing import Pool
import sys
import logging
from logging.handlers import QueueHandler
from datetime import datetime
import os
import time
import json
from enum import Enum
import tempfile
import magic
from typing import Optional, Dict, Any
from dotenv import load_dotenv
from datetime import timezone

# File handling
import py7zr
import pyzipper
from magika import Magika

# S3 and database
from minio import Minio
import clickhouse_connect

load_dotenv(override=True)

class UploadResult(Enum):
    CORRECTLY = 0
    FAILED = 1
    SKIPPED = 2  # For duplicates

class FileNameFormatter(logging.Formatter):
    def format(self, record):
        record.filenameinfo = getattr(record, "filenameinfo", "unknown")
        return super().format(record)

def setup_logger(log_file, filename):
    """Set up a logger for a specific file"""
    logger = logging.getLogger(filename)
    if not logger.handlers:
        if os.getenv("SERVER_ENV") == "prod":
            logger.setLevel(logging.INFO)
        else:
            logger.setLevel(logging.DEBUG)
            
        # Create file handler
        handler = logging.FileHandler(log_file)
        formatter = FileNameFormatter(
            "%(asctime)s - %(filenameinfo)s - %(levelname)s - %(message)s"
        )
        handler.setFormatter(formatter)
        logger.addHandler(handler)
        logger.propagate = False
    return logger

def logger_thread(log_queue, log_file):
    handler = logging.FileHandler(log_file)
    formatter = FileNameFormatter(
        "%(asctime)s - %(filenameinfo)s - %(levelname)s - %(message)s"
    )
    handler.setFormatter(formatter)

    while True:
        try:
            record = log_queue.get()
            if record is None:
                break
            message = formatter.format(record)
            handler.stream.write(message + "\n")
            handler.stream.flush()
        except Exception:
            import traceback
            print("[ERR] Error in logger thread:", file=sys.stderr)
            traceback.print_exc(file=sys.stderr)

def get_s3_key(sha256: str, is_archived: bool, original_ext: str = None) -> str:
    """
    Generate S3 key using sharding pattern with appropriate extension
    
    Args:
        sha256: The file's SHA256 hash
        is_archived: Whether the file was already archived (zip/7z)
        original_ext: The original file extension (if any)
    """
    # If file was already archived, keep its extension
    if is_archived and original_ext and original_ext.lower() in ['.zip', '.7z']:
        extension = original_ext
    else:
        # For files we archived ourselves, use .zip
        extension = '.zip'
        
    return f"{sha256[:2]}/{sha256[2:4]}/{sha256}{extension}"

def process_single_file(args):
    """Independent worker function for processing a single file"""
    filepath, file_number, total_files, config, log_file = args
    filename = os.path.basename(filepath)
    base_logger = setup_logger(log_file, filename)
    extra = {"filenameinfo": filename}
    logger = logging.LoggerAdapter(base_logger, extra)
    s3_client = None
    ch_client = None

    try:
        logger.info(f"Processing file {file_number}/{total_files}: {filepath}")

        # Create connections for this process
        s3_client = Minio(
            config["s3_endpoint"],
            access_key=config["s3_access_key"],
            secret_key=config["s3_secret_key"],
            secure=True
        )
        
        ch_client = clickhouse_connect.get_client(
            host=config['clickhouse_host'],
            port=config['clickhouse_port'],
            username=config['clickhouse_user'],
            password=config['clickhouse_password'],
            database=config['clickhouse_database'],
            verify=config['clickhouse_verify']
        )

        # Process the file and get contents
        ext = os.path.splitext(filepath.lower())[1]
        is_archived = ext in ['.zip', '.7z']

        with tempfile.TemporaryDirectory() as temp_dir:
            try:
                if filename.startswith("."):
                    logger.debug(f"Skipping hidden file: {filename}")
                    return UploadResult.SKIPPED

                elif ext == ".zip":
                    logger.debug(f"Processing ZIP file: {filepath}")
                    with pyzipper.AESZipFile(filepath) as zf:
                        zf.pwd = b"infected"
                        filename = zf.namelist()[0]
                        zf.extractall(temp_dir)
                        extracted_path = os.path.join(temp_dir, filename)
                        
                        with open(extracted_path, "rb") as f:
                            file_content = f.read()
                        with open(filepath, "rb") as f:
                            archive_content = f.read()
                            
                elif ext == ".7z":
                    logger.debug(f"Processing 7z file: {filepath}")
                    with py7zr.SevenZipFile(filepath, mode="r", password="infected") as z:
                        z.extractall(path=temp_dir)
                        # Get first file in the archive
                        for root, _, files in os.walk(temp_dir):
                            if files:
                                filename = files[0]
                                extracted_path = os.path.join(root, filename)
                                break
                                
                        with open(extracted_path, "rb") as f:
                            file_content = f.read()
                        with open(filepath, "rb") as f:
                            archive_content = f.read()
                else:
                    logger.debug(f"Processing non-archived file: {filepath}")
                    # For non-archived files, create password protected zip
                    with open(filepath, "rb") as f:
                        file_content = f.read()
                    filename = os.path.basename(filepath)
                    
                    # Create password protected zip
                    with tempfile.NamedTemporaryFile(delete=False) as temp_zip:
                        with pyzipper.AESZipFile(
                            temp_zip.name,
                            'w',
                            compression=pyzipper.ZIP_LZMA,
                            encryption=pyzipper.WZ_AES
                        ) as zf:
                            zf.pwd = b'infected'
                            zf.writestr(filename, file_content)
                        
                        with open(temp_zip.name, 'rb') as f:
                            archive_content = f.read()
                    
                    os.unlink(temp_zip.name)

                # Calculate hash
                sha256 = hashlib.sha256(file_content).hexdigest()
                # s3_key = f"{sha256[:2]}/{sha256[2:4]}/{sha256}"
                s3_key = get_s3_key(sha256, is_archived, ext if is_archived else None)
                logger.debug(f"Calculated SHA256: {sha256}")

                # Check if exists in S3
                try:
                    s3_client.stat_object(config["s3_bucket"], s3_key)
                    exists = True
                    logger.debug(f"File exists in S3: {s3_key}")
                except:
                    exists = False
                    logger.debug(f"File does not exist in S3: {s3_key}")

                # Prepare metadata
                max_timestamp = int(datetime(9999, 12, 31, 23, 59, 59, tzinfo=timezone.utc).timestamp() * 1000)
                now = datetime.now(timezone.utc)
                now_timestamp = int(now.timestamp() * 1000)
                inverted_timestamp = datetime.fromtimestamp((max_timestamp - now_timestamp)/1000, tz=timezone.utc)


                data = [[
                    sha256,                     # String
                    filename,                   # String
                    config['repository'],       # String
                    len(file_content),         # UInt64
                    magic.from_buffer(file_content),        # String
                    magic.from_buffer(file_content, mime=True),  # String
                    Magika().identify_bytes(file_content).output.ct_label,  # String
                    now,                       # upload_date
                    now,                       # first_seen
                    inverted_timestamp,        # version_date for replacing
                    config['s3_bucket'],       # String
                    s3_key,                    # String
                    config['notes'] if config['notes'] else None  # Nullable(String)
                ]]

                column_names = [
                    'sha256', 'filename', 'repository', 'file_size',
                    'filetype', 'filetype_mime', 'filetype_magika',
                    'upload_date', 'first_seen', 'version_date', 's3_bucket', 's3_key', 'notes'
                ]

                column_type_names = [
                    'String', 'String', 'LowCardinality(String)', 'UInt64',
                    'String', 'String', 'String',
                    'DateTime64(3, \'UTC\')', 'DateTime64(3, \'UTC\')', 
                    'DateTime64(3, \'UTC\')', 'String', 'String', 'Nullable(String)'
                ]
                
                if exists:
                    # Just update database
                    try:
                        ch_client.insert(
                            'samples_catalog',
                            data,
                            column_names=column_names,
                            column_type_names=column_type_names,
                            settings={'input_format_values_interpret_expressions': 0}
                        )
                        logger.info(f"Updated metadata for existing file: {sha256}")
                    except Exception as e:
                        logger.error(f"Error inserting metadata: {str(e)}")
                        import traceback
                        logger.error(f"Full traceback: {traceback.format_exc()}")
                    return UploadResult.SKIPPED
                else:
                    try:    
                        # Upload to S3 and insert metadata
                        import io
                        file_data = io.BytesIO(archive_content)
                        s3_client.put_object(
                            bucket_name=config['s3_bucket'],
                                object_name=s3_key,
                                data=file_data,
                                length=len(archive_content)
                            )
                        logger.info(f"Uploaded to S3: {s3_key}")
                    except Exception as e:
                        logger.error(f"Error uploading to S3: {str(e)}")
                        import traceback
                        logger.error(f"Full traceback: {traceback.format_exc()}")
                        return UploadResult.FAILED
                    
                    try:
                        ch_client.insert(
                            'samples_catalog',
                            data,
                            column_names=column_names,
                            column_type_names=column_type_names,
                            settings={'input_format_values_interpret_expressions': 0}
                        )
                        logger.info(f"Successfully processed file: {sha256}")
                        return UploadResult.CORRECTLY
                    except Exception as e:
                        logger.error(f"Error inserting metadata: {str(e)}")
                        import traceback
                        logger.error(f"Full traceback: {traceback.format_exc()}")
                        return UploadResult.FAILED

            except Exception as e:
                logger.error(f"Error processing file: {str(e)}")
                import traceback
                logger.error(f"Full traceback: {traceback.format_exc()}")
                return UploadResult.FAILED

    except Exception as e:
        logger.error(f"Error in worker: {str(e)}")
        return UploadResult.FAILED
    finally:
        # if s3_client:
        #     s3_client.close()
        if ch_client:
            ch_client.close()
        if base_logger and base_logger.handlers:
            for handler in base_logger.handlers:
                handler.close()
            base_logger.handlers.clear()

class S3Uploader:
    def __init__(self, path: str, repository: str, notes: Optional[str] = None):
        """
        Initialize S3 uploader
        
        Args:
            path: Path to file or directory to process
            repository: Repository name
            notes: Optional notes to add to all files
        """
        self.path = path
        self.repository = repository
        self.notes = notes
        
        # Initialize multiprocessing components
        self.manager = multiprocessing.Manager()
        # self.log_queue = self.manager.Queue()
        self.total_results = self.manager.dict({result: 0 for result in UploadResult})
        
        # Set up logging
        self.today = datetime.today().strftime("%Y%m%dT%H%M%S")
        # self.log_file = os.getenv("LOG_FILE_PATH", "./logs/") + f"{self.today}-{self.repository}-upload.txt"
        log_base_path = os.getenv("LOG_FILE_PATH")
        if not log_base_path:
            log_base_path = os.path.join(os.getcwd(), "logs")  # Default to ./logs directory
        self.log_file = os.path.join(log_base_path, f"{self.today}-{self.repository}-upload.txt")
        os.makedirs(os.path.dirname(self.log_file), exist_ok=True)

        # Initialize S3 client
        self.s3_client = Minio(
            os.getenv("S3_ENDPOINT"),
            access_key=os.getenv("S3_ACCESS_KEY"),
            secret_key=os.getenv("S3_SECRET_KEY"),
            secure=True  # Set to False if not using HTTPS
        )
        self.bucket_name = os.getenv("S3_BUCKET")

        # Initialize ClickHouse client
        self.ch_client = clickhouse_connect.get_client(
            host=os.getenv('CLICKHOUSE_HOST'),
            port=os.getenv('CLICKHOUSE_PORT'),
            username=os.getenv('CLICKHOUSE_USER'),
            password=os.getenv('CLICKHOUSE_PASSWORD'),
            database=os.getenv('CLICKHOUSE_DATABASE'),
            verify=os.getenv('CLICKHOUSE_ENFORCE_SSL', 'False')
        )
        
        # Ensure database table exists
        self._create_table()

    def _create_table(self):
        """Create the file catalog table if it doesn't exist"""
        create_table_query = """
            CREATE TABLE IF NOT EXISTS samples_catalog (
                sha256 String,
                filename String,
                repository LowCardinality(String),
                file_size UInt64,
                filetype String,
                filetype_mime String,
                filetype_magika String,
                upload_date DateTime64(3, 'UTC'),
                first_seen DateTime64(3, 'UTC'),
                version_date DateTime64(3, 'UTC'),  -- This will be inverted timestamp
                s3_bucket String,
                s3_key String,
                notes Nullable(String),
                PRIMARY KEY (sha256, repository)
            ) ENGINE = ReplacingMergeTree(version_date)
            ORDER BY (sha256, repository)
        """
        self.ch_client.command(create_table_query)

    # # def upload(self):
    # #     """Main upload function with multiprocessing support"""
    # #     start_time = time.time()

    # #     config = {
    # #         "s3_endpoint": os.getenv("S3_ENDPOINT"),
    # #         "s3_access_key": os.getenv("S3_ACCESS_KEY"),
    # #         "s3_secret_key": os.getenv("S3_SECRET_KEY"),
    # #         "s3_bucket": os.getenv("S3_BUCKET"),
    # #         "clickhouse_host": os.getenv("CLICKHOUSE_HOST"),
    # #         "clickhouse_port": os.getenv("CLICKHOUSE_PORT"),
    # #         "clickhouse_user": os.getenv("CLICKHOUSE_USER"),
    # #         "clickhouse_password": os.getenv("CLICKHOUSE_PASSWORD"),
    # #         "clickhouse_database": os.getenv("CLICKHOUSE_DATABASE"),
    # #         "clickhouse_verify": os.getenv("CLICKHOUSE_ENFORCE_SSL", "False"),
    # #         "repository": self.repository,
    # #         "notes": self.notes
    # #     }

    # #     try:
    # #         # Get list of files
    # #         if os.path.isfile(self.path):
    # #             files = [self.path] if not self.path.endswith('.txt') else [
    # #                 line.strip() for line in open(self.path) 
    # #                 if line.strip() and not os.path.basename(line.strip()).startswith('.')
    # #             ]
    # #         elif os.path.isdir(self.path):
    # #             files = [
    # #                 os.path.join(root, file)
    # #                 for root, _, files in os.walk(self.path)
    # #                 for file in files
    # #                 if not file.startswith('.')
    # #             ]
    # #         else:
    # #             print(f"[ERR] Invalid path: {self.path}")
    # #             return

    # #         total_files = len(files)
    # #         print(f"Found {total_files} files to process")

    # #         with Pool(processes=max(1, multiprocessing.cpu_count() - 1)) as pool:
    # #             results = pool.map(
    # #                 process_single_file,
    # #                 [(f, i + 1, total_files, config, self.log_file) for i, f in enumerate(files)]
    # #             )

    # #         # Update statistics
    # #         for result in results:
    # #             if result is not None:
    # #                 self.total_results[result] += 1

    # #         # Generate summary
    # #         end_time = time.time()
    # #         elapsed_time = end_time - start_time
    # #         elapsed_time_pretty = time.strftime("%H:%M:%S", time.gmtime(elapsed_time))

    # #         summary = (
    # #             f"\n\nUpload finished for {self.path}"
    # #             f"\nTime required: {elapsed_time_pretty}"
    # #             f"\nResults:"
    # #             f"\n- Total processed: {sum(self.total_results.values())}"
    # #             f"\n- Successfully uploaded: {self.total_results[UploadResult.CORRECTLY]}"
    # #             f"\n- Skipped (already exists): {self.total_results[UploadResult.SKIPPED]}"
    # #             f"\n- Failed: {self.total_results[UploadResult.FAILED]}\n"
    # #         )

    # #         with open(self.log_file, "a") as f:
    # #             f.write(summary)

    # #         print(summary)

    # #     except Exception as e:
    # #         print(f"[ERR] Error in upload process: {str(e)}")

    # def upload(self):
    #     """Main upload function with multiprocessing support"""
    #     start_time = time.time()
    #     BATCH_SIZE = 1000  # Process files in batches of 1000

    #     config = {
    #         "s3_endpoint": os.getenv("S3_ENDPOINT"),
    #         "s3_access_key": os.getenv("S3_ACCESS_KEY"),
    #         "s3_secret_key": os.getenv("S3_SECRET_KEY"),
    #         "s3_bucket": os.getenv("S3_BUCKET"),
    #         "clickhouse_host": os.getenv("CLICKHOUSE_HOST"),
    #         "clickhouse_port": os.getenv("CLICKHOUSE_PORT"),
    #         "clickhouse_user": os.getenv("CLICKHOUSE_USER"),
    #         "clickhouse_password": os.getenv("CLICKHOUSE_PASSWORD"),
    #         "clickhouse_database": os.getenv("CLICKHOUSE_DATABASE"),
    #         "clickhouse_verify": os.getenv("CLICKHOUSE_ENFORCE_SSL", "False"),
    #         "repository": self.repository,
    #         "notes": self.notes
    #     }

    #     try:
    #         # Get list of files
    #         if os.path.isfile(self.path):
    #             files = [self.path] if not self.path.endswith('.txt') else [
    #                 line.strip() for line in open(self.path) 
    #                 if line.strip() and not os.path.basename(line.strip()).startswith('.')
    #             ]
    #         elif os.path.isdir(self.path):
    #             files = [
    #                 os.path.join(root, file)
    #                 for root, _, files in os.walk(self.path)
    #                 for file in files
    #                 if not file.startswith('.')
    #             ]
    #         else:
    #             print(f"[ERR] Invalid path: {self.path}")
    #             return

    #         total_files = len(files)
    #         print(f"Found {total_files} files to process")

    #         # Process files in batches
    #         for i in range(0, total_files, BATCH_SIZE):
    #             batch_files = files[i:i + BATCH_SIZE]
    #             batch_start = i + 1
    #             batch_end = min(i + BATCH_SIZE, total_files)
    #             print(f"\nProcessing batch {batch_start}-{batch_end} of {total_files}")
                
    #             with Pool(processes=max(1, multiprocessing.cpu_count() - 1)) as pool:
    #                 batch_results = pool.map(
    #                     process_single_file,
    #                     [(f, j + 1, total_files, config, self.log_file) 
    #                         for j, f in enumerate(batch_files, start=i)]
    #                 )
                    
    #                 # Update statistics for this batch
    #                 for result in batch_results:
    #                     if result is not None:
    #                         self.total_results[result] += 1

    #                 # Print intermediate summary
    #                 print(f"Batch {batch_start}-{batch_end} completed:")
    #                 print(f"- Successfully uploaded: {sum(1 for r in batch_results if r == UploadResult.CORRECTLY)}")
    #                 print(f"- Skipped (exists): {sum(1 for r in batch_results if r == UploadResult.SKIPPED)}")
    #                 print(f"- Failed: {sum(1 for r in batch_results if r == UploadResult.FAILED)}")

    #         # Generate final summary
    #         end_time = time.time()
    #         elapsed_time = end_time - start_time
    #         elapsed_time_pretty = time.strftime("%H:%M:%S", time.gmtime(elapsed_time))

    #         summary = (
    #             f"\n\nUpload finished for {self.path}"
    #             f"\nTime required: {elapsed_time_pretty}"
    #             f"\nResults:"
    #             f"\n- Total processed: {sum(self.total_results.values())}"
    #             f"\n- Successfully uploaded: {self.total_results[UploadResult.CORRECTLY]}"
    #             f"\n- Skipped (already exists): {self.total_results[UploadResult.SKIPPED]}"
    #             f"\n- Failed: {self.total_results[UploadResult.FAILED]}\n"
    #         )

    #         with open(self.log_file, "a") as f:
    #             f.write(summary)

    #         print(summary)

    #     except Exception as e:
    #         print(f"[ERR] Error in upload process: {str(e)}")

    def upload(self):
        """Main upload function with multiprocessing support"""
        start_time = time.time()
        BATCH_SIZE = 1000  # Process files in batches of 1000

        config = {
            "s3_endpoint": os.getenv("S3_ENDPOINT"),
            "s3_access_key": os.getenv("S3_ACCESS_KEY"),
            "s3_secret_key": os.getenv("S3_SECRET_KEY"),
            "s3_bucket": os.getenv("S3_BUCKET"),
            "clickhouse_host": os.getenv("CLICKHOUSE_HOST"),
            "clickhouse_port": os.getenv("CLICKHOUSE_PORT"),
            "clickhouse_user": os.getenv("CLICKHOUSE_USER"),
            "clickhouse_password": os.getenv("CLICKHOUSE_PASSWORD"),
            "clickhouse_database": os.getenv("CLICKHOUSE_DATABASE"),
            "clickhouse_verify": os.getenv("CLICKHOUSE_ENFORCE_SSL", "False"),
            "repository": self.repository,
            "notes": self.notes
        }

        try:
            # Get all existing filenames for this repository
            query = f"SELECT filename FROM samples_catalog WHERE repository = '{self.repository}'"
            # existing_files = set()
            # for row in self.ch_client.query(query).result_rows:
            #     filename = os.path.splitext(row[0])[0]  # Strip extension
            #     existing_files.add(filename)
            existing_files = set(row[0] for row in self.ch_client.query(query).result_rows)
            print(f"Found {len(existing_files)} existing files in repository")

            # Get list of files to process
            if os.path.isfile(self.path):
                files = [self.path] if not self.path.endswith('.txt') else [
                    line.strip() for line in open(self.path) 
                    if line.strip() and not os.path.basename(line.strip()).startswith('.')
                ]
            elif os.path.isdir(self.path):
                files = [
                    os.path.join(root, file)
                    for root, _, files in os.walk(self.path)
                    for file in files
                    if not file.startswith('.')
                ]
            else:
                print(f"[ERR] Invalid path: {self.path}")
                return

            # Filter out files that are already in the repository
            files_to_process = []
            for f in files:
                basename = os.path.splitext(os.path.basename(f))[0]
                if basename not in existing_files:
                    files_to_process.append(f)

            total_files = len(files_to_process)
            skipped_files = len(files) - total_files
            print(f"Found {total_files} new files to process (skipped {skipped_files} existing files)")

            if total_files == 0:
                print("No new files to process")
                return

            # Process files in batches
            for i in range(0, total_files, BATCH_SIZE):
                batch_files = files_to_process[i:i + BATCH_SIZE]
                batch_start = i + 1
                batch_end = min(i + BATCH_SIZE, total_files)
                print(f"\nProcessing batch {batch_start}-{batch_end} of {total_files}")
                
                with Pool(processes=max(1, multiprocessing.cpu_count() - 1)) as pool:
                    batch_results = pool.map(
                        process_single_file,
                        [(f, j + 1, total_files, config, self.log_file) 
                        for j, f in enumerate(batch_files, start=i)]
                    )
                    
                    # Update statistics for this batch
                    for result in batch_results:
                        if result is not None:
                            self.total_results[result] += 1

                    # Print intermediate summary
                    print(f"Batch {batch_start}-{batch_end} completed:")
                    print(f"- Successfully uploaded: {sum(1 for r in batch_results if r == UploadResult.CORRECTLY)}")
                    print(f"- Skipped (exists): {sum(1 for r in batch_results if r == UploadResult.SKIPPED)}")
                    print(f"- Failed: {sum(1 for r in batch_results if r == UploadResult.FAILED)}")

            # Generate final summary
            end_time = time.time()
            elapsed_time = end_time - start_time
            elapsed_time_pretty = time.strftime("%H:%M:%S", time.gmtime(elapsed_time))

            summary = (
                f"\n\nUpload finished for {self.path}"
                f"\nTime required: {elapsed_time_pretty}"
                f"\nResults:"
                f"\n- Files already in repository: {skipped_files}"
                f"\n- New files processed: {total_files}"
                f"\n- Successfully uploaded: {self.total_results[UploadResult.CORRECTLY]}"
                f"\n- Skipped (already exists): {self.total_results[UploadResult.SKIPPED]}"
                f"\n- Failed: {self.total_results[UploadResult.FAILED]}\n"
            )

            with open(self.log_file, "a") as f:
                f.write(summary)

            print(summary)

        except Exception as e:
            print(f"[ERR] Error in upload process: {str(e)}")
            import traceback
            print(traceback.format_exc())

if __name__ == "__main__":
    import argparse

    parser = argparse.ArgumentParser(description='Upload malware samples to S3 and catalog them.')
    parser.add_argument('path', help='Path to file or directory to process')
    parser.add_argument('repository', help='Repository name')
    parser.add_argument('--notes', help='Optional notes to add to all files', default=None)
    
    args = parser.parse_args()
    
    uploader = S3Uploader(args.path, args.repository, args.notes)
    uploader.upload()